// DOM(文档对象模型):
// document:表示整个文档,包含网页的内容和结构。
// getElementById:通过元素的id属性获取元素节点。
// getElementsByTagName:通过元素的标签名获取元素节点集合。
// createElement:创建一个新的元素节点。
// appendChild:将一个元素节点添加到指定节点的子节点列表末尾。
// removeChild:从指定节点的子节点列表中移除一个子节点。
// innerHTML:获取或设置元素的HTML内容。
;;
(function () {
bodavm.envFunc.CSSStyleDeclaration_getPropertyValue=function (){
let arg=arguments[0]
if (arg=='color'){
let thisNode=bodavm.toolsFunc.getProtoAttr.call(this,this)
// debugger
let color=boda$(thisNode).html()
let colorgb=''
switch (color){
case 'green':
colorgb= 'rgb(0, 128, 0)'
break
case 'red':
colorgb='rgb(255, 0, 0)'
break
case 'black':
colorgb='rgb(0, 0, 0)'
break
case 'secondp':
colorgb="rgb(0, 0, 255)"
break
case 'bar':
colorgb="rgb(255, 0, 0)"
break
default :
console.log_copy(`CSSStyleDeclaration_getPropertyValue -> `,color,`未实现!!!!!!!`)
}
console.log_copy(`CSSStyleDeclaration_getPropertyValue arg ->`,arg ,` -> rgb ->`,colorgb)
return colorgb
}
console.log_copy(`CSSStyleDeclaration_getPropertyValue arg ->`,arg ,`未实现!!!!!!!!!!!`)
}
bodavm.envFunc.Element_remove=function (){
let thisNode=bodavm.toolsFunc.getProtoAttr.call(this,this)
if (!thisNode){
return bodavm.toolsFunc.throwError('typeError','错误thisNode不存在!!!!!!!!!11')
}
boda$(thisNode).remove()
console.log_copy(this, ` -> Element_remove`)
}
bodavm.envFunc.CSSRuleList_length_get=function (){
// debugger
let len=Object.keys(this,'bobo').length
console.log_copy(this, ` -> CSSRuleList_length_get length-> `, len)
return len
}
bodavm.envFunc.CSSStyleSheet_cssRules_get = function () {
let islive = bodavm.toolsFunc.getProtoAttr.call(this, 'cssRules')
if (islive) {
console.log_copy(this, ` -> CSSStyleSheet_cssRules_get cache已存在返回-> `, islive)
return islive
}
let rule = new CSSRuleList('bobo')
// let thisNode=bodavm.toolsFunc.getProtoAttr.call(this,this)
// debugger
console.log_copy(this, ` -> CSSStyleSheet_cssRules_get 默认返回一个 需要根据实际进行调整!!!!!-> `,)
Object.defineProperty_bo(rule, '0', {
value: new CSSStyleRule('bobo'),
writable: false,
enumerable: true,
configurable: true
})
rule=bodavm.toolsFunc.proxy2(rule,'CSSRuleList::proxy2')
bodavm.toolsFunc.setProtoAttr.call(this,'cssRules',rule)
return rule
}
bodavm.envFunc.HTMLStyleElement_sheet_get = function () {
let islive = bodavm.toolsFunc.getProtoAttr.call(this, 'sheet')
if (islive) {
console.log_copy(this, ` -> HTMLStyleElement_sheet_get cache已存在返回-> `, islive)
return islive
}
let thisNode = bodavm.toolsFunc.getProtoAttr.call(this, this)
// debugger
let isinDom = boda$('style').get().indexOf(thisNode)
if (isinDom == -1) {
console.log_copy(this, ` -> HTMLStyleElement_sheet_get 不存在html中返回null-> `, null)
return null
}
let sheet = new CSSStyleSheet('bobo')
bodavm.toolsFunc.setProtoAttr.call(this, 'sheet', sheet)
// bodavm.toolsFunc.setProtoAttr.call(sheet, sheet, thisNode)
console.log_copy(this, ` -> HTMLStyleElement_sheet_get sheet-> `, sheet)
return sheet
}
bodavm.envFunc.Node_replaceChild = function () {
let newChild = arguments[0]
let oldChild = arguments[1]
let parentNode = bodavm.toolsFunc.getProtoAttr.call(this, this)
// debugger
console.log_copy(this, ` -> Node_replaceChild newChild-> `, newChild, ` -> oldChild -> `, oldChild)
let newChildNode = bodavm.toolsFunc.getProtoAttr.call(newChild, newChild)
let oldChildNode = bodavm.toolsFunc.getProtoAttr.call(oldChild, oldChild)
// debugger
boda$(oldChildNode).replaceWith(boda$(newChildNode));
return oldChild
}
bodavm.envFunc.Node_cloneNode = function () {
let deep = arguments[0]
let thisNode = bodavm.toolsFunc.getProtoAttr.call(this, this)
let cloneNode = null
let resNode = null
if (deep) {
cloneNode = boda$(thisNode).get(0)
resNode = bodavm.toolsFunc.setProto(cloneNode.name)
// bodavm.toolsFunc.setProto.call
bodavm.toolsFunc.setProtoAttr.call(resNode, resNode, cloneNode)
}
else {
let attrs = boda$(thisNode).attr()
cloneNode = document.createElement(thisNode.name)
if (attrs) {
for (let i in attrs) {
cloneNode[i] = attrs[i]
}
}
resNode = cloneNode
}
console.log_copy(this, ` -> Node_cloneNode deep -> ${arguments[0]} -> res ->`, resNode)
// debugger
return resNode
}
bodavm.envFunc.CharacterData_data_set = function () {
let arg = arguments[0]
let thisNode = bodavm.toolsFunc.getProtoAttr.call(this, this)
// debugger
boda$(thisNode).text(arguments[0])
console.log_copy(this, ` -> CharacterData_data_set arg -> arg`)
return arg
}
bodavm.envFunc.DOMRectList_length_get = function () {
console.log_copy(this, ` -> DOMRectList_length_get res -> 默认返回1`)
return 1
}
bodavm.envFunc.Element_getClientRects = function () {
let getClientRects = new DOMRectList('bobo')
console.log_copy(this, ` -> Element_getClientRects getClientRects -> `, getClientRects)
Object.defineProperty_bo(getClientRects, '0', {
value: new DOMRect('bobo'),
writable: false,
enumerable: true,
configurable: true
})
return getClientRects
}
bodavm.envFunc.HTMLElement_innerText_set = function () {
// debugger
let arg = arguments[0]
let thisNode = bodavm.toolsFunc.getProtoAttr.call(this, this)
boda$(thisNode).empty()
boda$(thisNode).text(arg)
console.log_copy(this, `-> HTMLElement_innerText_set innerText -> `, arg)
return arg
}
bodavm.envFunc.HTMLElement_style_set = function () {
// debugger
let style = arguments[0]
let thisNode = bodavm.toolsFunc.getProtoAttr.call(this, this)
boda$(thisNode).attr('style', style)
console.log_copy(this, `- > HTMLElement_style_set style -> `, style)
return style
}
bodavm.envFunc.HTMLElement_dataset_get = function () {
let islive = bodavm.toolsFunc.getProtoAttr.call(this, 'dataset')
if (islive) {
console.log_copy(this, `-> HTMLElement_dataset_get 已存在返回`, islive)
return islive
}
let dataset = new DOMStringMap('bobo')
bodavm.toolsFunc.setProtoAttr.call(this, 'dataset', dataset)
console.log_copy(`HTMLElement_dataset_get -> xr -> ${dataset}`)
return dataset
}
bodavm.envFunc.Document_pointerLockElement_get = function () {
let pointerLockElement = bodavm.toolsFunc.getProtoAttr.call(this, 'pointerLockElement') ? bodavm.toolsFunc.getProtoAttr.call(this, 'pointerLockElement') : null
console.log_copy(`Document_pointerLockElement_get res->`, pointerLockElement)
return pointerLockElement
}
bodavm.envFunc.Document_pictureInPictureElement_get = function () {
let pictureInPictureElement = bodavm.toolsFunc.getProtoAttr.call(this, 'pictureInPictureElement') ? bodavm.toolsFunc.getProtoAttr.call(this, 'pictureInPictureElement') : null
console.log_copy(`Document_pictureInPictureElement_get res->`, pictureInPictureElement)
return pictureInPictureElement
}
bodavm.envFunc.Document_xmlVersion_get = function () {
let xmlVersion = bodavm.toolsFunc.getProtoAttr.call(this, 'xmlVersion') ? bodavm.toolsFunc.getProtoAttr.call(this, 'xmlVersion') : null
console.log_copy(`Document_xmlVersion_get res->`, xmlVersion)
return xmlVersion
}
bodavm.envFunc.Document_xmlEncoding_get = function () {
let xmlEncoding = bodavm.toolsFunc.getProtoAttr.call(this, 'xmlEncoding') ? bodavm.toolsFunc.getProtoAttr.call(this, 'xmlEncoding') : null
console.log_copy(`Document_xmlEncoding_get res->`, xmlEncoding)
return xmlEncoding
}
bodavm.envFunc.Document_ontransitionrun_get = function () {
let ontransitionrun = bodavm.toolsFunc.getProtoAttr.call(this, 'ontransitionrun') ? bodavm.toolsFunc.getProtoAttr.call(this, 'ontransitionrun') : null
console.log_copy(`Document_ontransitionrun_get res->`, ontransitionrun)
return ontransitionrun
}
bodavm.envFunc.Document_ontransitionend_get = function () {
let ontransitionend = bodavm.toolsFunc.getProtoAttr.call(this, 'ontransitionend') ? bodavm.toolsFunc.getProtoAttr.call(this, 'ontransitionend') : null
console.log_copy(`Document_ontransitionend_get res->`, ontransitionend)
return ontransitionend
}
bodavm.envFunc.Document_ontransitioncancel_get = function () {
let ontransitioncancel = bodavm.toolsFunc.getProtoAttr.call(this, 'ontransitioncancel') ? bodavm.toolsFunc.getProtoAttr.call(this, 'ontransitioncancel') : null
console.log_copy(`Document_ontransitioncancel_get res->`, ontransitioncancel)
return ontransitioncancel
}
bodavm.envFunc.Document_pictureInPictureEnabled_get = function () {
console.log_copy(`Document_pictureInPictureEnabled_get res-> 默认返回true`, true)
return true
}
bodavm.envFunc.Document_onresume_get = function () {
let onresume = bodavm.toolsFunc.getProtoAttr.call(this, 'onresume') ? bodavm.toolsFunc.getProtoAttr.call(this, 'onresume') : null
console.log_copy(`Document_onresume_get res->`, onresume)
return onresume
}
bodavm.envFunc.Document_onpointerlockerror_get = function () {
let onpointerlockerror = bodavm.toolsFunc.getProtoAttr.call(this, 'onpointerlockerror') ? bodavm.toolsFunc.getProtoAttr.call(this, 'onpointerlockerror') : null
console.log_copy(`Document_onpointerlockerror_get res->`, onpointerlockerror)
return onpointerlockerror
}
bodavm.envFunc.Document_featurePolicy_get = function () {
let isfeaturePolicy = bodavm.toolsFunc.getProtoAttr.call(this, 'featurePolicy')
if (isfeaturePolicy) {
console.log_copy(`Document_featurePolicy_get cache已存在返回->`, isfeaturePolicy)
return isfeaturePolicy
}
let feature = new FeaturePolicy('boob')
console.log_copy(`Document_featurePolicy_get res->`, feature)
bodavm.toolsFunc.setProtoAttr.call(this, 'featurePolicy', feature)
return feature
}
bodavm.envFunc.Document_onmousemove_get = function () {
let onmousemove = bodavm.toolsFunc.getProtoAttr.call(this, 'onmousemove') ? bodavm.toolsFunc.getProtoAttr.call(this, 'onmousemove') : null
console.log_copy(`Document_onmousemove_get res->`, onmousemove)
return onmousemove
}
bodavm.envFunc.HTMLElement_onmouseenter_get = function () {
let onmouseenter = bodavm.toolsFunc.getProtoAttr.call(this, 'onmouseenter')
console.log_copy(`HTMLElement_onmouseenter_get -> res -> `, onmouseenter)
return onmouseenter
}
bodavm.envFunc.Document_scrollingElement_get = function () {
let ele = document.documentElement
console.log_copy(`Document_scrollingElement_get ->默认返回html`, ele)
return ele
}
bodavm.envFunc.HTMLElement_onresize_get = function () {
// let onresize=bodavm.memory.asyncEvent['HTMLElement']['onresize']
// if (!onresize.length) {
// console.log_copy(`HTMLElement_onresize_get res->`,null)
// return null
// }
let onresize = bodavm.toolsFunc.getProtoAttr.call(this, 'onresize') ? bodavm.toolsFunc.getProtoAttr.call(this, 'onresize') : null
console.log_copy(`HTMLElement_onresize_get res->`, onresize)
return onresize
}
bodavm.envFunc.Document_onselectionchange_get = function () {
let res = bodavm.toolsFunc.getProtoAttr.call(this, 'onselectionchange') ? bodavm.toolsFunc.getProtoAttr.call(this, 'onselectionchange') : null
console.log_copy(`Document_onselectionchange_get -> res->`, res)
return res
}
bodavm.envFunc.URL_createObjectURL = function () {
debugger
let arg = arguments[0]
let newUrl = `blob:${location.origin}/661f4a1e-88f8-44e8-9d85-635b0b7bbb3e`
console.log_copy(`URL_createObjectURL arg->`, arg, `-> res->`, newUrl)
return newUrl
}
bodavm.envFunc.HTMLScriptElement_async_set = function () {
let async = arguments[0]
bodavm.toolsFunc.setProtoAttr.call(this, 'async', async)
console.log_copy(this, `-> HTMLScriptElement_async_set arg->`, async)
return async
}
bodavm.envFunc.Document_querySelectorAll = function () {
let arg = arguments[0]
// boda$(thisNode)
// let resNodeList=boda$('html').find(arg).splice(0,1)
let resNodeList = boda$('html').find(arg)
// debugger
let nodeList = []
if (resNodeList) {
for (const resNode of resNodeList) {
let newNode=null
let isliveNode=bodavm.toolsFunc.getProtoAttr.call(resNode,resNode)
if (isliveNode){
newNode=isliveNode
}else{
newNode = bodavm.toolsFunc.setProto(resNode.name)
bodavm.toolsFunc.setProtoAttr.call(resNode, resNode, newNode)
}
// let newNode = bodavm.toolsFunc.setProto(resNode.name)
bodavm.toolsFunc.setProtoAttr.call(newNode, newNode, resNode)
nodeList.push(newNode)
}
}
nodeList.__proto__ = NodeList.prototype
console.log_copy(this, `-> Element_querySelector res->`, nodeList)
return nodeList
}
bodavm.envFunc.Element_innerHTML_get = function () {
let thisNode = bodavm.toolsFunc.getProtoAttr.call(this, this)
// debugger
let html = boda$(thisNode).html()
console.log_copy(this, ` -> Element_innerHTML_get -> res ->`, html)
return html
}
bodavm.envFunc.Element_firstElementChild_get = function () {
let thisNode = bodavm.toolsFunc.getProtoAttr.call(this, this)
// debugger
let target = boda$(thisNode).children().first()[0]
let newNode=null
let isliveNode=bodavm.toolsFunc.getProtoAttr.call(target,target)
if (isliveNode){
newNode=isliveNode
}else{
newNode = bodavm.toolsFunc.setProto(target.name)
bodavm.toolsFunc.setProtoAttr.call(target, target, newNode)
}
// let newNode = bodavm.toolsFunc.setProto(target.name)
bodavm.toolsFunc.setProtoAttr.call(newNode, newNode, target)
console.log_copy(this, ` -> Element_firstElementChild_get -> res ->`, newNode)
return newNode
}
bodavm.envFunc.Document_createTextNode = function () {
// debugger
let arg = arguments[0]
let textnode = boda$(boda$.parseHTML(arg)).get(0)
// debugger
let newNode = bodavm.toolsFunc.setProto('TEXT')
bodavm.toolsFunc.setProtoAttr.call(textnode,textnode,newNode)
bodavm.toolsFunc.setProtoAttr.call(newNode, newNode, textnode)
console.log_copy(this, ` -> Document_createTextNode -> res ->`, newNode)
return newNode
}
bodavm.envFunc.Document_dir_set = function () {
let arg = arguments[0]
bodavm.memory.document['dir'] = arg
console.log_copy(`Document_dir_set -> arg`, arg)
return arg
}
bodavm.envFunc.Document_title_set = function () {
let arg = arguments[0]
if (arg == "ltr" || arg == 'rtl') {
bodavm.memory.document['title'] = arg
}
console.log_copy(`Document_title_set -> arg`, arg)
return arg
}
bodavm.envFunc.Element_clientHeight_get = function () {
let thisNode = bodavm.toolsFunc.getProtoAttr(this) ? bodavm.toolsFunc.getProtoAttr(this) : bodavm.toolsFunc.getProtoAttr.call(this, this)
if (thisNode.name == 'html' || thisNode.name == 'body') {
console.log_copy(`Element_clientHeight_get -> 当前node为 nodeName`, thisNode.name, ` 返回809`)
return 809
}
else {
console.log_copy(`Element_clientWidth_get 正在执行错误`, thisNode.name, '未实现')
}
}
bodavm.envFunc.Element_clientWidth_get = function () {
let thisNode = bodavm.toolsFunc.getProtoAttr(this) ? bodavm.toolsFunc.getProtoAttr(this) : bodavm.toolsFunc.getProtoAttr.call(this, this)
if (thisNode.name == 'html' || thisNode.name == 'body') {
console.log_copy(`Element_clientWidth_get ->当前node为 nodeName`, thisNode.name, ` 返回1440`)
return 1440
} else {
console.log_copy(`Element_clientWidth_get 正在执行错误`, thisNode.name, '未实现')
}
}
bodavm.envFunc.Document_currentScript_get = function () {
let currentNode = bodaCurrentElement
if (currentNode.name == 'script') {
let newNode=null
let isliveNode=bodavm.toolsFunc.getProtoAttr.call(currentNode,currentNode)
if (isliveNode){
newNode=isliveNode
}else{
newNode = bodavm.toolsFunc.setProto(currentNode.name)
bodavm.toolsFunc.setProtoAttr.call(currentNode, currentNode, newNode)
}
bodavm.toolsFunc.setProtoAttr.call(newNode, newNode, currentNode)
console.log_copy(this, `-> Document_currentScript_get -> res ->`, newNode)
return newNode
} else {
console.log_copy(this, `-> Document_currentScript_get ->,当前不处于script标签内,直接返回null`)
return null
}
}
bodavm.envFunc.Node_nextSibling_get = function () {
let thisNode = bodavm.toolsFunc.getProtoAttr.call(this, this)
// debugger
let nextNode = thisNode.nextSibling
if (bodavm.memory.cache["Node_nextSibling_get"]['this'] && bodavm.memory.cache["Node_nextSibling_get"]['this'] == this) {
let cacheValue = bodavm.memory.cache["Node_nextSibling_get"]['res'];
console.log_copy(`Node_nextSibling_get 已存在,直接从cache中取值`, 'res- >', cacheValue);
return cacheValue;
}
// debugger
if (!nextNode) {
console.log_copy(this, `-> Node_nextSibling_get res- >`, null);
return null
}
let name = nextNode.name ? nextNode.name : nextNode.type
let newNode=null
let isliveNode=bodavm.toolsFunc.getProtoAttr.call(nextNode,nextNode)
if (isliveNode){
newNode=isliveNode
}else{
newNode = bodavm.toolsFunc.setProto(name)
bodavm.toolsFunc.setProtoAttr.call(nextNode, nextNode, newNode)
}
bodavm.toolsFunc.setProtoAttr.call(newNode, newNode, nextNode)
bodavm.memory.cache["Node_nextSibling_get"]['this'] = this
bodavm.memory.cache["Node_nextSibling_get"]['res'] = newNode
console.log_copy(this, `-> Node_nextSibling_get res- >`, newNode);
return newNode
}
bodavm.envFunc.Node_nodeType_get = function () {
let thisNode = bodavm.toolsFunc.getProtoAttr.call(this, this)
// debugger
let nodetype = boda$(thisNode)[0].nodeType
console.log_copy(this, `-> Node_nodeType_get nodetype- >`, nodetype);
return nodetype
}
bodavm.envFunc.Node_firstChild_get = function () {
if (bodavm.memory.cache["Node_firstChild_get"]['this'] == this) {
let cacheValue = bodavm.memory.cache["Node_firstChild_get"]['res'];
console.log_copy(`Node_firstChild_get 已存在,直接从cache中取值`, 'res- >', cacheValue);
return cacheValue;
}
let thisNode = bodavm.toolsFunc.getProtoAttr.call(this, this)
let node_ = boda$(thisNode).children()[0]
// debugger
if (!node_) {
console.log_copy(this, `-> Node_firstChild_get res->`, null)
return null
}
let newNode=null
let isliveNode=bodavm.toolsFunc.getProtoAttr.call(node_,node_)
if (isliveNode){
newNode=isliveNode
}else{
newNode = bodavm.toolsFunc.setProto(node_.name)
bodavm.toolsFunc.setProtoAttr.call(node_, node_, newNode)
}
bodavm.toolsFunc.setProtoAttr.call(newNode, newNode, node_)
console.log_copy(this, `-> Node_firstChild_get res->`, newNode)
bodavm.memory.cache["Node_firstChild_get"]['this'] = this
bodavm.memory.cache["Node_firstChild_get"]['res'] = newNode
return newNode
}
bodavm.envFunc.Element_tagName_get = function () {
// debugger
let thisNode = bodavm.toolsFunc.getProtoAttr.call(this, this)
let tagName_ = boda$(thisNode).prop('tagName')
console.log_copy(this, `-> Element_tagName_get tagName_->`, tagName_)
return tagName_
}
bodavm.envFunc.HTMLMetaElement_content_get = function () {
let thisNode = bodavm.toolsFunc.getProtoAttr.call(this, this)
let cont_ = boda$(thisNode).attr('content')
console.log_copy(this, `-> HTMLMetaElement_content_get res->`, cont_)
return cont_
}
bodavm.envFunc.Node_parentElement_get = function () {
let thisNode = bodavm.toolsFunc.getProtoAttr.call(this, this)
// debugger
if (bodavm.memory.cache["Node_parentElement_get"]['this'] == this) {
let cacheValue = bodavm.memory.cache["Node_parentElement_get"]['res'];
console.log_copy(`Node_parentElement_get 已存在,直接从cache中取值`, 'res- >', cacheValue);
return cacheValue;
}
let parentEle = boda$(thisNode).parent()[0]
if (thisNode.name == 'html') {
console.log_copy(this, `-> Node_parentElement_get res->`, null)
return null
}
// debugger
let newNode =null
let isliveNode=bodavm.toolsFunc.getProtoAttr.call(parentEle,parentEle)
if (isliveNode){
newNode=isliveNode
}else{
newNode=bodavm.toolsFunc.setProto(parentEle.name)
bodavm.toolsFunc.setProtoAttr.call(parentEle,parentEle,newNode)
}
// =
bodavm.toolsFunc.setProtoAttr.call(newNode, newNode, parentEle)
console.log_copy(this, `-> Node_parentElement_get res->`, newNode)
bodavm.memory.cache['Node_parentElement_get']['res'] = newNode
bodavm.memory.cache['Node_parentElement_get']['this'] = this
return newNode
}
bodavm.envFunc.Element_setAttribute = function () {
let name = arguments[0]
let value = arguments[1]
let thisNode = bodavm.toolsFunc.getProtoAttr.call(this, this)
let res = boda$(thisNode).attr(name, value)
console.log_copy(this, `-> Element_getAttribute name-> `, name, `-> value ->`, value)
// return res
}
bodavm.envFunc.Element_getAttribute = function () {
let arg = arguments[0]
let thisNode = bodavm.toolsFunc.getProtoAttr.call(this, this)
let res = boda$(thisNode).attr(arg)
console.log_copy(this, `-> Element_getAttribute `, `arg->`, arg, `-> res-> `, res)
return res
}
bodavm.envFunc.Node_childNodes_get = function () {
let thisNode = bodavm.toolsFunc.getProtoAttr.call(this, this)
// debugger
let childs = thisNode.children
let childNodes = []
if (bodavm.memory.cache['Node_childNodes_get']['this'] == this) {
let cacheValue = bodavm.memory.cache['Node_childNodes_get']['res']
console.log_copy(this, `-> Node_childNodes_get 已存在,直接从cache中取值`, ' -> res- >', cacheValue)
return cacheValue
}
if (childs) {
for (let child of childs) {
if (child.type === 'tag' || child.type === 'text') {
// debugger
let newNode=null
let isliveNode=bodavm.toolsFunc.getProtoAttr.call(child,child)
if (isliveNode){
newNode=isliveNode
}else{
let name = child.name ? child.name : child.type
newNode = bodavm.toolsFunc.setProto(name)
bodavm.toolsFunc.setProtoAttr.call(child,child,newNode)
bodavm.toolsFunc.setProtoAttr.call(newNode, newNode, child)
}
childNodes.push(newNode);
}
}
}
childNodes.__proto__ = NodeList.prototype
bodavm.memory.cache['Node_childNodes_get']['this'] = this
bodavm.memory.cache['Node_childNodes_get']['res'] = childNodes
console.log_copy(this, `-> Node_childNodes_get `, 'res- >', childNodes)
return childNodes
}
bodavm.envFunc.Element_className_set = function () {
// debugger
let arg = arguments[0]
let thisNode = bodavm.toolsFunc.getProtoAttr.call(this, this)
boda$(thisNode).attr('class', arg)
console.log_copy(this, `-> Element_className_set ->`, arg)
return arg
}
bodavm.envFunc.Element_querySelector = function () {
// debugger
let arg = arguments[0]
let thisNode = bodavm.toolsFunc.getProtoAttr.call(this, this)
boda$(thisNode)
let resNode = boda$(thisNode).find(arg)
let newNode = null
if (resNode) {
let isliveNode=bodavm.toolsFunc.getProtoAttr.call(resNode[0],resNode[0])
if (isliveNode){
console.log_copy(this,`Element_querySelector arg->`, arg, ` -> res->`, isliveNode)
return isliveNode
}
newNode = bodavm.toolsFunc.setProto(resNode[0].name)
bodavm.toolsFunc.setProtoAttr.call(resNode[0], resNode[0], newNode)
bodavm.toolsFunc.setProtoAttr.call(newNode, newNode, resNode[0])
}
console.log_copy(this, `-> Element_querySelector arg ->` ,arg, `-> res->`, newNode)
return newNode
}
bodavm.envFunc.DOMTokenList_add = function () {
let thisNode = bodavm.toolsFunc.getProtoAttr.call(this, this)
this.__proto__ = Array.prototype
this.push(arguments[0])
boda$(thisNode).attr('class', arguments[0])
this.__proto__ = DOMTokenList.prototype
console.log_copy(this, `-> DOMTokenList_add arg->`, arguments[0])
return arguments[0]
}
bodavm.envFunc.Node_insertBefore = function () {
let target = arguments[0]
let target2 = arguments[1]
let thisNode = bodavm.toolsFunc.getProtoAttr.call(this, this)
let newNode = bodavm.toolsFunc.getProtoAttr.call(target, target)
let referenceNode = bodavm.toolsFunc.getProtoAttr.call(target2, target2)
// debugger
let newEl = boda$(newNode);
if (newNode.name == 'script' && referenceNode.name == 'script') {
debugger
bodavm.memory.waitExec.push(targetNode)
}
if (!referenceNode) {
// referenceNode 为 null,插入到最后
// debugger
boda$(thisNode).append(newEl);
} else {
// debugger
const ref = boda$(referenceNode);
ref.before(newEl);
}
console.log_copy(this, `-> Node_insertBefore newNode->`, target, `-> referenceNode ->`, target2)
return target
}
bodavm.envFunc.Document_querySelector = function () {
// debugger
let arg = arguments[0]
let res = boda$(arg).get()[0]
let newNode = null
if (res) {
let isliveNode=bodavm.toolsFunc.getProtoAttr.call(res,res)
if (isliveNode){
console.log_copy(`Document_querySelector arg->`, arg, ` -> res->`, isliveNode)
return isliveNode
}
newNode = bodavm.toolsFunc.setProto(res.name)
bodavm.toolsFunc.setProtoAttr.call(res, res, newNode)
bodavm.toolsFunc.setProtoAttr.call(newNode, newNode, res)
}
console.log_copy(this, `-> Document_querySelector arg-> `, arg, ` -> res->`, newNode)
return newNode
}
// bodavm.envFunc.DOMTokenList_toString=function (){
// debugger
// }
bodavm.envFunc.Element_classList_get = function () {
let thisNode = bodavm.toolsFunc.getProtoAttr.call(this, this)
let classNames = boda$(thisNode).attr('class');
let clsList = []
// debugger
if (classNames) {
clsList = classNames.trim().split(/\s+/);
}
clsList.__proto__ = DOMTokenList.prototype
// return [];
// debugger
console.log_copy(this, `-> Element_classList_get res->`, clsList)
// bodavm.toolsFunc.setProtoAttr.call(clsList,clsList,thisNode)
return clsList
}
bodavm.envFunc.HTMLScriptElement_src_set = function () {
let arg = arguments[0]
// debugger
let thisNode = bodavm.toolsFunc.getProtoAttr.call(this, this)
boda$(thisNode).attr('src', arg)
// debugger
console.log_copy(this, `-> HTMLScriptElement_src_set arg->`, arg)
return arg
}
bodavm.envFunc.Image_src_set = function () {
let arg = arguments[0]
// debugger
let thisNode = bodavm.toolsFunc.getProtoAttr.call(this, this)
boda$(thisNode).attr('src', arg)
// debugger
console.log_copy(this, `-> Image_src_set arg->`, arg)
return arg
}
bodavm.envFunc.Image_alt_set = function () {
let arg = arguments[0]
// debugger
let thisNode = bodavm.toolsFunc.getProtoAttr.call(this, this)
boda$(thisNode).attr('alt', arg)
// debugger
console.log_copy(this, `-> Image_alt_set arg->`, arg)
return arg
}
bodavm.envFunc.Document_getElementById = function () {
let arg = arguments[0]
let element = boda$(`#${arg}`)
let res = null
if (element.length > 0) {
res = element[0]
let isliveNode=bodavm.toolsFunc.getProtoAttr.call(res,res)
if (isliveNode){
console.log_copy(`Document_getElementById arg->`, arg, ` -> res->`, isliveNode)
return isliveNode
}
let newNode = bodavm.toolsFunc.setProto(res.name)
bodavm.toolsFunc.setProtoAttr.call(res,res,newNode)
bodavm.toolsFunc.setProtoAttr.call(newNode, newNode, res)
console.log_copy(`Document_getElementById arg->`, arg, ` -> res->`, newNode)
return newNode;
}
console.log_copy(`Document_getElementById arg->`, arg, ` -> res->`, res)
// debugger
return res;
}
bodavm.envFunc.Image_width_get = function () {
let width = bodavm.toolsFunc.getProtoAttr.call(this, 'width') ? bodavm.toolsFunc.getProtoAttr.call(this, 'width') : 0
console.log_copy(this, ` -> Image_width_get res-> `, width)
return width
}
bodavm.envFunc.PointerEvent_pointerId_get = function () {
console.log_copy(this, ` -> PointerEvent_pointerId_get res-> 默认返回`, 1)
return 1
}
bodavm.envFunc.PointerEvent_isPrimary_get = function () {
console.log_copy(this, ` -> PointerEvent_isPrimary_get res-> 默认返回`, false)
return false
}
bodavm.envFunc.HTMLElement_onerror_get = function () {
let onerr = bodavm.toolsFunc.getProtoAttr.call(this, 'onerror')
console.log_copy(`HTMLElement_onerror_get res->`, onerr)
return onerr
}
bodavm.envFunc.Document_title_get = function () {
// debugger
let title = bodavm.memory.document['title']
console.log_copy(`Document_title_get res->`, title)
return title
}
bodavm.envFunc.Document_referrer_get = function () {
// debugger
let refer = bodavm.memory.document['referrer']
console.log_copy(`Document_referrer_get res->`, refer)
return refer
}
bodavm.envFunc.Document_wasDiscarded_get = function () {
console.log_copy(`Document_wasDiscarded_get 默认返回 false`)
return false
}
bodavm.envFunc.HTMLElement_onclick_set = function () {
let onclick = arguments[0]
// debugger
let event = {
'self': this,
'callback': onclick
}
bodavm.memory.asyncEvent['HTMLElement']['onclick'].push(event)
// bodavm.toolsFunc.setProtoAttr.call(this, 'onload', onlod)
console.log_copy(this, ` -> HTMLElement_onclick_set res->`, onclick);
return onclick
}
bodavm.envFunc.HTMLElement_onchange_set = function () {
let onchange = arguments[0]
// debugger
let event = {
'self': this,
'callback': onchange
}
bodavm.memory.asyncEvent['HTMLElement']['onchange'].push(event)
// bodavm.toolsFunc.setProtoAttr.call(this, 'onload', onlod)
console.log_copy(this, ` -> HTMLElement_onchange_set res->`, onchange);
return onchange
}
bodavm.envFunc.HTMLElement_onkeydown_set = function () {
let onkeydown = arguments[0]
// debugger
let event = {
'self': this,
'callback': onkeydown
}
bodavm.memory.asyncEvent['HTMLElement']['onkeydown'].push(event)
// bodavm.toolsFunc.setProtoAttr.call(this, 'onload', onlod)
console.log_copy(this, ` -> HTMLElement_onkeydown_set res->`, onkeydown);
return onkeydown
}
bodavm.envFunc.HTMLElement_onload_set = function () {
let onlod = arguments[0]
// debugger
let event = {
'self': this,
'callback': onlod
}
bodavm.memory.asyncEvent['HTMLElement']['onload'].push(event)
// bodavm.toolsFunc.setProtoAttr.call(this, 'onload', onlod)
console.log_copy(this, ` -> HTMLElement_onload_set res->`, onlod);
return onlod
}
bodavm.envFunc.HTMLElement_onerror_set = function () {
let onerr = arguments[0]
// debugger
let event = {
'self': this,
'callback': onerr
}
bodavm.memory.asyncEvent['HTMLElement']['onerror'].push(event)
console.log_copy(this, `-> HTMLElement_onerror_set res->`, onerr);
return onerr
}
bodavm.envFunc.HTMLScriptElement_src_get = function () {
// debugger
let thisNode = bodavm.toolsFunc.getProtoAttr.call(this, this) ? bodavm.toolsFunc.getProtoAttr.call(this, this) : bodavm.toolsFunc.getProtoAttr(this)
// debugger
let src_ = boda$(thisNode).attr()['src'] ? boda$(thisNode).attr()['src'] : null
console.log_copy(`HTMLScriptElement_src_get res->`, src_)
return src_
}
bodavm.envFunc.DOMRectReadOnly_top_get = function () {
// debugger
console.log_copy(`DOMRectReadOnly_top_get res-> 默认返回`, 8)
return 8
}
bodavm.envFunc.DOMRectReadOnly_bottom_get = function () {
// debugger
console.log_copy(`DOMRectReadOnly_bottom_get res-> 默认返回`, 245.33334350585938)
return 245.33334350585938
}
bodavm.envFunc.DOMRectReadOnly_left_get = function () {
// debugger
console.log_copy(`DOMRectReadOnly_left_get res-> 默认返回`, 8)
return 8
}
bodavm.envFunc.DOMRectReadOnly_right_get = function () {
// debugger
console.log_copy(`DOMRectReadOnly_right_get res-> 默认返回`, 1432)
return 1432
}
bodavm.envFunc.DOMRect_height_get = function () {
// debugger
console.log_copy(`DOMRect_height_get res-> 默认返回`, 237.33334350585938)
return 1424
}
bodavm.envFunc.DOMRect_width_get = function () {
// debugger
console.log_copy(`DOMRect_width_get res-> 默认返回`, 1424)
return 1424
}
bodavm.envFunc.DOMRect_y_get = function () {
// debugger
console.log_copy(`DOMRect_y_get res-> 默认返回`, 8)
return 8
}
bodavm.envFunc.DOMRect_x_get = function () {
// debugger
console.log_copy(`DOMRect_x_get res-> 默认返回`, 8)
return 8
}
bodavm.envFunc.Element_getBoundingClientRect = function () {
let DomRect = new DOMRect('bobo')
console.log_copy(`Element_getBoundingClientRect res->`, DomRect)
return DomRect
}
bodavm.envFunc.Element_clientTop_get = function () {
// debugger
let thisEvent = bodavm.toolsFunc.getProtoAttr.call(this, this)
console.log_copy(`Element_clientTop_get 当前事件为 -->`, thisEvent, ` - >默认返回 0`)
return 0
}
bodavm.envFunc.Element_clientLeft_get = function () {
// debugger
let thisEvent = bodavm.toolsFunc.getProtoAttr.call(this, this)
console.log_copy(`Element_clientLeft_get 当前事件为 -->`, thisEvent, ` - >默认返回 0`)
return 0
}
bodavm.envFunc.Element_scrollTop_get = function () {
// debugger
let thisEvent = bodavm.toolsFunc.getProtoAttr.call(this, this)
console.log_copy(`Element_scrollTop_get 当前事件为 -->`, thisEvent, ` - >默认返回 0`)
return 0
}
bodavm.envFunc.Element_scrollLeft_get = function () {
// debugger
let thisEvent = bodavm.toolsFunc.getProtoAttr.call(this, this)
console.log_copy(`Element_scrollLeft_get 当前事件为 -->`, thisEvent, ` - >默认返回 0`)
return 0
}
bodavm.envFunc.MouseEvent_pageY_get = function () {
// debugger
let thisEvent = bodavm.toolsFunc.getProtoAttr.call(this, this)
console.log_copy(`MouseEvent_pageY_get 当前事件为 -->`, thisEvent, ` - >默认返回 0`)
return 0
}
bodavm.envFunc.MouseEvent_pageX_get = function () {
// debugger
let thisEvent = bodavm.toolsFunc.getProtoAttr.call(this, this)
console.log_copy(`MouseEvent_pageX_get 当前事件为 -->`, thisEvent, ` - >默认返回 0`)
return 0
}
bodavm.envFunc.Event_target_get = function () {
// debugger
let thisEvent = bodavm.toolsFunc.getProtoAttr.call(this, this)
console.log_copy(`Event_target_get 当前事件为 -->`, thisEvent, ` - >默认返回 body`)
if (thisEvent == 'click' || thisEvent == 'mousemove') {
return document.body
} else {
return bodavm.toolsFunc.throwError('TypeError', `Event_target_get 未实现`)
}
}
bodavm.envFunc.Event_srcElement_get = function () {
// debugger
let thisEvent = bodavm.toolsFunc.getProtoAttr.call(this, this)
console.log_copy(`Event_srcElement_get 当前事件为 -->`, thisEvent, ` - >默认返回 body`)
if (thisEvent == 'click' || thisEvent == 'mousemove') {
return document.body
} else {
return bodavm.toolsFunc.throwError('TypeError', `Event_srcElement_get 未实现`)
}
}
bodavm.envFunc.MediaQueryList_matches_get = function () {
let matches_ = bodavm.toolsFunc.getProtoAttr.call(this, 'matchMedia')
// debugger
let ismatch=null
switch (matches_){
case '(prefers-color-scheme: dark)':
ismatch=false
break
case "(prefers-color-scheme: light)":
ismatch=true
break
case "(prefers-color-scheme: no-preference)":
ismatch=false
break
case "(prefers-reduced-motion: no-preference)":
ismatch=true
break
case "(prefers-reduced-motion: reduce)":
ismatch=false
break
case '(any-pointer: fine )':
ismatch=true
break
case '(any-pointer: coarse )':
ismatch=false
break
case '(any-pointer: none )':
ismatch=false
break
case '(any-pointer )':
ismatch=true
break
case '(any-hover: hover )':
ismatch=true
break
case '(any-hover: on-demand )':
ismatch=false
break
case '(any-hover: none )':
ismatch=false
break
case '(any-hover )':
ismatch=true
break
case '(color-gamut: srgb )':
ismatch=true
break
case '(color-gamut: p3 )':
ismatch=false
break
case '(color-gamut: rec2020 )':
ismatch=false
break
case '(color-gamut )':
ismatch=true
break
default:
console.log_copy(`MediaQueryList_matches_get -> `,matches_,`未实现!!!!!`)
}
console.log_copy(`MediaQueryList_matches_get -> matches_ `,matches_, `-> res ->${ismatch}`);
return ismatch
}
bodavm.envFunc.Node_removeChild = function () {
if (bodavm.config.isdebug) {
debugger;
}
;
// debugger
let targetNode = bodavm.toolsFunc.getProtoAttr(arguments[0]) ? bodavm.toolsFunc.getProtoAttr(arguments[0]) : bodavm.toolsFunc.getProtoAttr.call(arguments[0], arguments[0]); //目标node
// debugger
let thisNode = bodavm.toolsFunc.getProtoAttr(this) ? bodavm.toolsFunc.getProtoAttr(this) : bodavm.toolsFunc.getProtoAttr.call(this, this);
if (bodavm.memory.cache['Element_getElementsByTagName'][targetNode.name]) {
// debugger
let collection = bodavm.memory.cache['Element_getElementsByTagName'][targetNode.name]['res']
for (const key in Object.getOwnPropertyDescriptors_bo(collection)) {
// debugger
if (collection[key] == arguments[0]) {
delete collection['bo' + key]
}
}
let newkeys = Object.keys(collection, 'bobo')
let newlen = newkeys.length
for (let index = 0; index < newlen; index++) {
// debugger
Object.defineProperty(collection, 'bo' + index, {
value: collection[newkeys[index]],
writable: false,
enumerable: true,
configurable: true
}, 'bobo')
}
delete collection['bo' + (newlen)]
}
if (bodavm.memory.cache['Document_getElementsByTagName'][targetNode.name]) {
// debugger
let collection = bodavm.memory.cache['Document_getElementsByTagName'][targetNode.name]['res']
for (const key in Object.getOwnPropertyDescriptors_bo(collection)) {
// debugger
if (collection[key] == arguments[0]) {
delete collection['bo' + key]
// debugger
}
}
// debugger
let newkeys = Object.keys(collection, 'bobo')
let newlen = newkeys.length
for (let index = 0; index < newlen; index++) {
// debugger
Object.defineProperty(collection, 'bo' + index, {
value: collection[newkeys[index]],
writable: false,
enumerable: true,
configurable: true
}, 'bobo')
}
delete collection['bo' + (newlen)]
// debugger
}
if (bodavm.memory.cache['Element_children_get'][thisNode.name]) {
// debugger
let collection = bodavm.memory.cache['Element_children_get'][thisNode.name]['res']
for (const key in Object.getOwnPropertyDescriptors_bo(collection)) {
// debugger
if (collection[key] == arguments[0]) {
delete collection['bo' + key]
// debugger
}
}
// debugger
let newkeys = Object.keys(collection, 'bobo')
let newlen = newkeys.length
for (let index = 0; index < newlen; index++) {
// debugger
Object.defineProperty(collection, 'bo' + index, {
value: collection[newkeys[index]],
writable: false,
enumerable: true,
configurable: true
}, 'bobo')
}
delete collection['bo' + (newlen)]
// debugger
}
// debugger
if (targetNode.name == 'script' && bodavm.memory.cache['Document_scripts_get']['res']) {
// debugger
let collection = bodavm.memory.cache['Document_scripts_get']['res']
for (const key in Object.getOwnPropertyDescriptors_bo(collection)) {
// debugger
if (collection[key] == arguments[0]) {
delete collection['bo' + key]
// debugger
}
}
// debugger
let newkeys = Object.keys(collection, 'bobo')
let newlen = newkeys.length
for (let index = 0; index < newlen; index++) {
// debugger
Object.defineProperty(collection, 'bo' + index, {
value: collection[newkeys[index]],
writable: false,
enumerable: true,
configurable: true
}, 'bobo')
}
delete collection['bo' + (newlen)]
// debugger
}
if (boda$(targetNode).attr('class') &&bodavm.memory.cache['Document_getElementsByClassName'][tagName][ boda$(targetNode).attr('class')] ){
let collection = bodavm.memory.cache['Document_getElementsByClassName']['res']
for (const key in Object.getOwnPropertyDescriptors_bo(collection)) {
// debugger
if (collection[key] == arguments[0]) {
delete collection['bo' + key]
// debugger
}
}
// debugger
let newkeys = Object.keys(collection, 'bobo')
let newlen = newkeys.length
for (let index = 0; index < newlen; index++) {
// debugger
Object.defineProperty(collection, 'bo' + index, {
value: collection[newkeys[index]],
writable: false,
enumerable: true,
configurable: true
}, 'bobo')
}
delete collection['bo' + (newlen)]
}
console.log_copy(`Node_removeChild `, `child->${arguments[0]}`);
// debugger
let childs = boda$(thisNode).children()
let isRemove = 0
for (let index = 0; index < childs.length; index++) {
if (childs[index] == targetNode) {
if (bodavm.memory.domDocument[targetNode.name]) {
let deldomDocInd = bodavm.memory.domDocument[targetNode.name].indexOf(targetNode)
let delalldomDocInd = bodavm.memory.domDocument['all'].indexOf(targetNode)
// debugger
bodavm.memory.domDocument[targetNode.name].splice(deldomDocInd, 1)
bodavm.memory.domDocument['all'].splice(delalldomDocInd)
boda$(thisNode).children().eq(index).remove()
}
isRemove = 1
break
}
}
if (isRemove == 0) {
return bodavm.toolsFunc.throwError("DOMException", "Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.");
}
return arguments[0];
};
bodavm.envFunc.HTMLCollection_length_get = function () {
let templen_ = 0
for (const key in Object.getOwnPropertyDescriptors_bo(this)) {
templen_ += 1
}
console.log_copy(`HTMLCollection_length_get res->`, templen_)
return templen_
}
bodavm.envFunc.Element_children_get = function () {
let thisNode = bodavm.toolsFunc.getProtoAttr.call(this, this)
// debugger
let tagName = thisNode.name
// debugger
if (!bodavm.memory.cache['Element_children_get'][tagName]) {
bodavm.memory.cache['Element_children_get'][tagName] = {}
bodavm.memory.cache['Element_children_get'][tagName]['res'] = {}
}
if (bodavm.memory.cache['Element_children_get'][tagName] && bodavm.memory.cache['Element_children_get'][tagName]['this'] == this) {
let curLen = Object.keys(bodavm.memory.cache['Element_children_get'][tagName]["res"]).length
// debugger
if (curLen == boda$(thisNode).children().length) {
let cacheValue = bodavm.memory.cache['Element_children_get'][tagName]["res"]
console.log_copy(this, `-> Element_children_get 已存在,直接从cache中取值`, `tagName ->`, tagName, ' -> res- >', cacheValue)
return cacheValue
}
}
let tempCollection = []
debugger
let childs = boda$(thisNode).children()
for (const child of childs) {
let newNode=null
let isliveNode=bodavm.toolsFunc.getProtoAttr.call(child,child)
if (isliveNode){
newNode=isliveNode
}else{
newNode = bodavm.toolsFunc.setProto(child.name)
bodavm.toolsFunc.setProtoAttr.call(child,child,newNode)
}
bodavm.toolsFunc.setProtoAttr.call(newNode, newNode, child)
tempCollection.push(newNode)
}
for (let index = 0; index < tempCollection.length; index++) {
Object.defineProperty(bodavm.memory.cache['Element_children_get'][tagName]['res'], index, {
value: tempCollection[index],
writable: false,
enumerable: true,
configurable: true
}, 'bobo')
}
// debugger
bodavm.memory.cache['Element_children_get'][tagName]['res'].__proto__ = HTMLCollection.prototype
bodavm.memory.cache['Element_children_get'][tagName]['this'] = this
bodavm.memory.cache['Element_children_get'][tagName]['this'].__proto__[Symbol.iterator] = Array.prototype[Symbol.iterator];
bodavm.memory.cache['Element_children_get'][tagName]['res'] = bodavm.toolsFunc.proxyHTMLCollection(bodavm.memory.cache['Element_children_get'][tagName]['res'], `HTMLCollection:proxyHTMLCollection`)
console.log_copy(this, `-> Element_children_get `, ' -> res- >', bodavm.memory.cache['Element_children_get'][tagName]['res'])
return bodavm.memory.cache['Element_children_get'][tagName]['res']
}
bodavm.envFunc.Document_scripts_get = function () {
let tagName = 'script'
let tempCollection = []
if (bodavm.memory.cache['Document_scripts_get']['res']) {
let curLen = Object.keys(bodavm.memory.cache['Document_scripts_get']["res"]).length
if (curLen == bodavm.memory.domDocument[tagName].length) {
let cacheValue = bodavm.memory.cache['Document_scripts_get']["res"]
console.log_copy(`Document_scripts_get 已存在,直接从cache中取值`, `tagName ->`, tagName, ' -> res- >', cacheValue)
return cacheValue
}
}
if (bodavm.memory.domDocument[tagName]) {
for (let ind = 0; ind < bodavm.memory.domDocument[tagName].length; ind++) {
let newNode = null
let currNode = bodavm.memory.domDocument[tagName][ind]
let isliveNode=bodavm.toolsFunc.getProtoAttr.call(currNode,currNode)
if (isliveNode){
newNode=isliveNode
}else{
newNode=bodavm.toolsFunc.setProto(tagName)
bodavm.toolsFunc.setProtoAttr.call(currNode,currNode,newNode)
}
bodavm.toolsFunc.setProtoAttr.call(newNode, newNode, currNode)
tempCollection.push(newNode)
}
}
bodavm.memory.cache['Document_scripts_get']['res'] = {}
for (let index = 0; index < tempCollection.length; index++) {
Object.defineProperty(bodavm.memory.cache['Document_scripts_get']['res'], index, {
value: tempCollection[index],
writable: false,
enumerable: true,
configurable: true
}, 'bobo')
}
bodavm.memory.cache['Document_scripts_get']['res'].__proto__ = HTMLCollection.prototype
bodavm.memory.cache['Document_scripts_get']['this'] = this
bodavm.memory.cache['Document_scripts_get']['res'].__proto__[Symbol.iterator] = Array.prototype[Symbol.iterator];
console.log_copy(`Document_scripts_get `, `arg ->`, tagName, ' -> res- >', bodavm.memory.cache['Document_scripts_get']['res'])
bodavm.memory.cache['Document_scripts_get']['res'] = bodavm.toolsFunc.proxyHTMLCollection(bodavm.memory.cache['Document_scripts_get']['res'], `HTMLCollection:proxyHTMLCollection`)
return bodavm.memory.cache['Document_scripts_get']['res'];
}
bodavm.envFunc.Document_getElementsByClassName = function () {
let tagName = arguments[0]
let classList = boda$(`.${tagName}`)
if (!bodavm.memory.cache['Document_getElementsByClassName'][tagName]) {
bodavm.memory.cache['Document_getElementsByClassName'][tagName] = {}
}
if (bodavm.memory.cache['Document_getElementsByClassName'][tagName] ) {
let curLen = Object.keys(bodavm.memory.cache['Document_getElementsByClassName'][tagName]["res"]).length
// debugger
if (curLen==bodavm.memory.cache['Document_getElementsByClassName'][tagName]['length']){
let cacheValue = bodavm.memory.cache['Document_getElementsByClassName'][tagName]["res"]
console.log_copy(`Document_getElementsByClassName 已存在,直接从cache中取值`, `tagName ->`, tagName, ' -> res- >', cacheValue)
return cacheValue
}
}
// debugger
// bodavm.memory.collection[tagName] = []
let tempCollection = []
if (classList) {
for (let ind = 0; ind < classList.length; ind++) {
let newNode=null
let isliveNode=bodavm.toolsFunc.getProtoAttr.call(classList[ind],classList[ind])
if (isliveNode){
newNode=isliveNode
}else{
newNode = bodavm.toolsFunc.setProto(classList[ind].name)
bodavm.toolsFunc.setProtoAttr.call(classList[ind], classList[ind], newNode)
}
let currNode = classList[ind]
bodavm.toolsFunc.setProtoAttr.call(newNode, newNode, currNode)
tempCollection = [].push(newNode)
}
}
for (let index = 0; index < tempCollection.length; index++) {
Object.defineProperty(bodavm.memory.cache['Document_getElementsByClassName'][tagName]['res'], index, {
value: tempCollection[index],
writable: false,
enumerable: true,
configurable: true
}, 'bobo')
}
// debugger
bodavm.memory.cache['Document_getElementsByClassName'][tagName]['res'].__proto__ = HTMLCollection.prototype
bodavm.memory.cache['Document_getElementsByClassName'][tagName]['length']=tempCollection.length
bodavm.memory.cache['Document_getElementsByClassName'][tagName]['res'].__proto__[Symbol.iterator] = Array.prototype[Symbol.iterator];
console.log_copy(`Document_getElementsByClassName `, `arg ->`, tagName, ' -> res- >', bodavm.memory.cache['Document_getElementsByClassName'][tagName]['res'])
bodavm.memory.cache['Document_getElementsByClassName'][tagName]['res'] = bodavm.toolsFunc.proxyHTMLCollection(bodavm.memory.cache['Document_getElementsByClassName'][tagName]['res'], `HTMLCollection:proxyHTMLCollection`)
return bodavm.memory.cache['Document_getElementsByClassName'][tagName]['res'];
}
bodavm.envFunc.Document_getElementsByTagName = function () {
if (bodavm.config.isdebug) {
debugger;
}
let tagName = arguments[0]
if (!bodavm.memory.cache['Document_getElementsByTagName'][tagName]) {
bodavm.memory.cache['Document_getElementsByTagName'][tagName] = {}
bodavm.memory.cache['Document_getElementsByTagName'][tagName]['res'] = {}
}
if (bodavm.memory.cache['Document_getElementsByTagName'][tagName] && bodavm.memory.cache['Document_getElementsByTagName'][tagName]['this'] == this) {
let curLen = Object.keys(bodavm.memory.cache['Document_getElementsByTagName'][tagName]["res"]).length
debugger
if (curLen == 0 || curLen == bodavm.memory.domDocument[tagName].length) {
let cacheValue = bodavm.memory.cache['Document_getElementsByTagName'][tagName]["res"]
console.log_copy(`Document_getElementsByTagName 已存在,直接从cache中取值`, `tagName ->`, tagName, ' -> res- >', cacheValue)
return cacheValue
}
}
// debugger
// bodavm.memory.collection[tagName] = []
let tempCollection = []
if (bodavm.memory.domDocument[tagName]) {
for (let ind = 0; ind < bodavm.memory.domDocument[tagName].length; ind++) {
let newNode = null
let currNode = bodavm.memory.domDocument[tagName][ind]
let isliveNode=bodavm.toolsFunc.getProtoAttr.call(currNode,currNode)
if (isliveNode){
newNode=isliveNode
}else{
newNode=bodavm.toolsFunc.setProto(tagName)
bodavm.toolsFunc.setProtoAttr.call(currNode,currNode,newNode)
}
bodavm.toolsFunc.setProtoAttr.call(newNode, newNode, currNode)
tempCollection.push(newNode)
}
}
for (let index = 0; index < tempCollection.length; index++) {
Object.defineProperty(bodavm.memory.cache['Document_getElementsByTagName'][tagName]['res'], index, {
value: tempCollection[index],
writable: false,
enumerable: true,
configurable: true
}, 'bobo')
}
// debugger
bodavm.memory.cache['Document_getElementsByTagName'][tagName]['res'].__proto__ = HTMLCollection.prototype
bodavm.memory.cache['Document_getElementsByTagName'][tagName]['this'] = this
// bodavm.memory.cache['Document_getElementsByTagName'][tagName]['length']=bodavm.memory.domDocument[tagName].length
bodavm.memory.cache['Document_getElementsByTagName'][tagName]['res'].__proto__[Symbol.iterator] = Array.prototype[Symbol.iterator];
console.log_copy(`Document_getElementsByTagName `, `arg ->`, tagName, ' -> res- >', bodavm.memory.cache['Document_getElementsByTagName'][tagName]['res'])
bodavm.memory.cache['Document_getElementsByTagName'][tagName]['res'] = bodavm.toolsFunc.proxyHTMLCollection(bodavm.memory.cache['Document_getElementsByTagName'][tagName]['res'], `HTMLCollection:proxyHTMLCollection`)
return bodavm.memory.cache['Document_getElementsByTagName'][tagName]['res'];
};
bodavm.envFunc.Element_getElementsByTagName = function () {
if (bodavm.config.isdebug) {
debugger;
}
///未完善 缺少
;
// debugger
let tagName = arguments[0]
if (!bodavm.memory.cache['Element_getElementsByTagName'][tagName]) {
bodavm.memory.cache['Element_getElementsByTagName'][tagName] = {}
bodavm.memory.cache['Element_getElementsByTagName'][tagName]['res'] = {}
}
if (bodavm.memory.cache['Element_getElementsByTagName'][tagName] && bodavm.memory.cache['Element_getElementsByTagName'][tagName]['this'] == this) {
let curLen = Object.keys(bodavm.memory.cache['Element_getElementsByTagName'][tagName]["res"]).length
// debugger
if (curLen == bodavm.memory.domDocument[tagName].length) {
let cacheValue = bodavm.memory.cache['Element_getElementsByTagName'][tagName]["res"]
console.log_copy(`Element_getElementsByTagName 已存在,直接从cache中取值`, `tagName ->`, tagName, ' -> res- >', cacheValue)
return cacheValue
}
}
// debugger
let elesList = bodavm.memory.domDocument[tagName]
let thisNode = bodavm.toolsFunc.getProtoAttr.call(this, this)
// let res={}
let tempCollection = []
if (elesList) {
let childrensList = boda$(thisNode).find('*').get() //获取所有子孙节点
for (let node of elesList) {
let indexele = childrensList.indexOf(node)
if (indexele != -1) {
let newNode=null
let isliveNode=bodavm.toolsFunc.getProtoAttr.call(node,node)
if (isliveNode){
newNode=isliveNode
}else{
newNode= bodavm.toolsFunc.setProto(tagName)
bodavm.toolsFunc.setProtoAttr.call(node, node, newNode)
}
// let newNode = bodavm.toolsFunc.setProto(tagName)
bodavm.toolsFunc.setProtoAttr.call(newNode, newNode, node)
tempCollection.push(newNode)
}
}
}
for (let index = 0; index < tempCollection.length; index++) {
Object.defineProperty(bodavm.memory.cache['Element_getElementsByTagName'][tagName]['res'], index, {
value: tempCollection[index],
writable: false,
enumerable: true,
configurable: true
}, 'bobo')
}
bodavm.memory.cache['Element_getElementsByTagName'][tagName]['res'].__proto__ = HTMLCollection.prototype
bodavm.memory.cache['Element_getElementsByTagName'][tagName]['this'] = this
// bodavm.memory.cache['Element_getElementsByTagName'][tagName]['length']=bodavm.memory.domDocument[tagName].length
// debugger
bodavm.memory.cache['Element_getElementsByTagName'][tagName]['res'].__proto__[Symbol.iterator] = Array.prototype[Symbol.iterator];
console.log_copy(this, `-> Element_getElementsByTagName `, `arg ->`, tagName, ' -> res- >', bodavm.memory.cache['Element_getElementsByTagName'][tagName]['res'])
bodavm.memory.cache['Element_getElementsByTagName'][tagName]['res'] = bodavm.toolsFunc.proxyHTMLCollection(bodavm.memory.cache['Element_getElementsByTagName'][tagName]['res'], `HTMLCollection:proxyHTMLCollection`)
return bodavm.memory.cache['Element_getElementsByTagName'][tagName]['res'];
};
bodavm.envFunc.HTMLFormElement_action_set = function () {
if (bodavm.config.isdebug) {
debugger;
}
;
let arg = arguments[0];
let thisNode = bodavm.toolsFunc.getProtoAttr(this) ? bodavm.toolsFunc.getProtoAttr(this) : bodavm.toolsFunc.getProtoAttr.call(this, this);
boda$(thisNode).attr('action', arg)
// debugger
console.log_copy(`HTMLFormElement_action_set arg->`, arg);
};
bodavm.envFunc.HTMLAllCollection_length_get = function () {
if (bodavm.config.isdebug) {
debugger;
}
;
// debugger;
let len = bodavm.memory.all.length;
console.log_copy(`HTMLAllCollection_length_get 长度-->`, len);
return len;
};
bodavm.envFunc.HTMLElement_innerText_get = function () {
if (bodavm.config.isdebug) {
debugger;
}
for (let input of bodavm.memory.form) {
for (let key in input) {
if (input[key] === 'innerText') {
console.log_copy(`HTMLElement_innerText_get ->`, input['this'])
return input['this'];
}
}
}
;
};
bodavm.envFunc.HTMLInputElement_name_get = function () {
if (bodavm.config.isdebug) {
debugger;
}
;
debugger
let thisNode = bodavm.toolsFunc.getProtoAttr(this) ? bodavm.toolsFunc.getProtoAttr(this) : bodavm.toolsFunc.getProtoAttr.call(this, this);
let res = boda$(thisNode).attr('name')
// debugger
console.log_copy(`HTMLInputElement_name_get res->`, res);
return res
};
bodavm.envFunc.Element_id_get = function () {
if (bodavm.config.isdebug) {
debugger;
}
;
// debugger
let thisNode = bodavm.toolsFunc.getProtoAttr(this) ? bodavm.toolsFunc.getProtoAttr(this) : bodavm.toolsFunc.getProtoAttr.call(this, this);
if (this instanceof HTMLFormElement) {
for (let input of bodavm.memory.form) {
for (let key in input) {
if (input[key] === 'id') {
console.log_copy(`Element_id_get ->`, input['this'])
return input['this'];
}
}
}
}
let id_ = boda$(thisNode).attr('id')
console.log_copy(`Element_id_get id->`, id_)
return id_
};
bodavm.envFunc.Node_textContent_get = function () {
if (bodavm.config.isdebug) {
debugger;
}
;
for (let input of bodavm.memory.form) {
for (let key in input) {
if (input[key] === 'textContent') {
console.log_copy(`Node_textContent_get ->`, input['this'])
return input['this'];
}
}
}
};
bodavm.envFunc.HTMLFormElement_action_get = function () {
if (bodavm.config.isdebug) {
debugger;
}
for (let input of bodavm.memory.form) {
for (let key in input) {
if (input[key] === 'action') {
// debugger
console.log_copy(`HTMLFormElement_action_get ->`, input['this'])
return input['this'];
}
}
}
;
// debugger
};
bodavm.envFunc.HTMLInputElement_type_set = function () {
if (bodavm.config.isdebug) {
debugger;
}
;
// debugger
let arg = arguments[0];
let thisNode = bodavm.toolsFunc.getProtoAttr(this) ? bodavm.toolsFunc.getProtoAttr(this) : bodavm.toolsFunc.getProtoAttr.call(this, this);
boda$(thisNode).attr('type', arg)
// debugger
let isForm = 0
if (this instanceof HTMLInputElement) {
for (let inp of bodavm.memory.form) {
if (inp['this'] == this) {
inp['type'] = arg
isForm = 1
break
}
}
if (isForm == 0) {
let _id = { 'this': this, 'type': arg }
bodavm.memory.form.push(_id)
}
}
console.log_copy(`HTMLInputElement_type_set arg->`, arg);
};
bodavm.envFunc.HTMLInputElement_name_set = function () {
if (bodavm.config.isdebug) {
debugger;
}
;
// debugger
let arg = arguments[0];
let thisNode = bodavm.toolsFunc.getProtoAttr(this) ? bodavm.toolsFunc.getProtoAttr(this) : bodavm.toolsFunc.getProtoAttr.call(this, this);
boda$(thisNode).attr('name', arg)
// debugger
let isForm = 0
if (this instanceof HTMLInputElement) {
for (let inp of bodavm.memory.form) {
if (inp['this'] == this) {
inp['name'] = arg
isForm = 1
break
}
}
if (isForm == 0) {
let _id = { 'this': this, 'name': arg }
bodavm.memory.form.push(_id)
}
}
console.log_copy(`HTMLInputElement_name_set arg->`, arg);
// debugger
};
bodavm.envFunc.HTMLAllCollection_item = function () {
// debugger
let item_ = arguments[0]
let res = bodavm.memory.all[item_]
console.log_copy(`HTMLAllCollection_item res->`, res)
return res
}
bodavm.envFunc.Element_id_set = function () {
if (bodavm.config.isdebug) {
debugger;
}
;
// debugger
let arg = arguments[0];
let thisNode = bodavm.toolsFunc.getProtoAttr(this) ? bodavm.toolsFunc.getProtoAttr(this) : bodavm.toolsFunc.getProtoAttr.call(this, this);
boda$(thisNode).attr('id', arg);
// debugger
let isForm = 0
if (this instanceof HTMLInputElement) {
for (let inp of bodavm.memory.form) {
if (inp['this'] == this) {
inp['id'] = arg
isForm = 1
break
}
}
if (isForm == 0) {
let _id = { 'this': this, 'id': arg }
bodavm.memory.form.push(_id)
}
}
console.log_copy(`Element_id_set id->`, arg);
return arguments[0];
};
bodavm.envFunc.Document_visibilityState_get = function Document_visibilityState_get() {
if (bodavm.config.isdebug) {
debugger;
}
;
console.log_copy("Document_visibilityState_get 未完善 visibilitychange事件来监听文档的可见性", 'visible');
return 'visible';
};
bodavm.envFunc.Document_createExpression = function () {
if (bodavm.config.isdebug) {
debugger;
}
;
// debugger
let xpath = new XPathExpression('bobo');
console.log_copy(`Document_createExpression `, `res ->${xpath}`);
return xpath;
};
bodavm.envFunc.MutationObserver_observe = function () {
if (bodavm.config.isdebug) {
debugger;
}
;
// debugger
let arg = arguments[0];
if (!arg) {
return bodavm.toolsFunc.throwError("TypeError", `Failed to execute 'observe' on 'MutationObserver': 1 argument required, but only 0 present.`);
}
if (!arg instanceof Node) {
return bodavm.toolsFunc.throwError("TypeError", `Failed to execute 'observe' on 'MutationObserver': parameter 1 is not of type 'Node'.`);
}
console.log_copy(`MutationObserver_observe 未完善 arg->`, arguments[0], ` -> arg1 ->`, JSON.stringify_bo(arguments[1]));
};
bodavm.envFunc.HTMLAnchorElement_origin_get = function () {
if (bodavm.config.isdebug) {
debugger;
}
;
let res = bodavm.memory.HTMLAnchorElement['origin'];
console.log_copy(`HTMLAnchorElement_origin_get `, `arg ->${res}`);
return res;
};
bodavm.envFunc.HTMLAnchorElement_hash_get = function () {
if (bodavm.config.isdebug) {
debugger;
}
;
let res = bodavm.memory.HTMLAnchorElement['hash'];
console.log_copy(`HTMLAnchorElement_hash_get `, `arg ->${res}`);
return res;
};
bodavm.envFunc.HTMLAnchorElement_search_get = function () {
if (bodavm.config.isdebug) {
debugger;
}
;
let res = bodavm.memory.HTMLAnchorElement['search'];
console.log_copy(`HTMLAnchorElement_search_get `, `arg ->${res}`);
return res;
};
bodavm.envFunc.HTMLAnchorElement_pathname_get = function () {
if (bodavm.config.isdebug) {
debugger;
}
;
let res = bodavm.memory.HTMLAnchorElement['pathname'];
console.log_copy(`HTMLAnchorElement_pathname_get `, `arg ->${res}`);
return res;
};
bodavm.envFunc.HTMLAnchorElement_port_get = function () {
if (bodavm.config.isdebug) {
debugger;
}
;
let res = bodavm.memory.HTMLAnchorElement['port'];
console.log_copy(`HTMLAnchorElement_port_get `, `arg ->${res}`);
return res;
};
bodavm.envFunc.HTMLAnchorElement_hostname_get = function () {
if (bodavm.config.isdebug) {
debugger;
}
;
let res = bodavm.memory.HTMLAnchorElement['hostname'];
console.log_copy(`HTMLAnchorElement_hostname_get `, `arg ->${res}`);
return res;
};
bodavm.envFunc.HTMLAnchorElement_protocol_get = function () {
if (bodavm.config.isdebug) {
debugger;
}
;
let res = bodavm.memory.HTMLAnchorElement['protocol'];
console.log_copy(`HTMLAnchorElement_protocol_get `, `arg ->${res}`);
return res;
};
bodavm.envFunc.HTMLAnchorElement_href_get = function () {
if (bodavm.config.isdebug) {
debugger;
}
;
let res = bodavm.memory.HTMLAnchorElement['href'];
console.log_copy(`HTMLAnchorElement_href_get `, `arg ->${res}`);
return res;
};
bodavm.envFunc.HTMLAnchorElement_href_set = function () {
if (bodavm.config.isdebug) {
debugger;
}
;
let arg = arguments[0];
// bodavm.memory.HTMLAnchorElement['href']=arg
let urls = new bodaParserURL(arg);
for (let ele in bodavm.memory.HTMLAnchorElement) {
bodavm.memory.HTMLAnchorElement[ele] = urls[ele];
}
// debugger
console.log_copy(`HTMLAnchorElement_href_set `, `arg ->${arg}`);
return arg;
};
bodavm.envFunc.HTMLAnchorElement_toString = function () {
if (bodavm.config.isdebug) {
debugger;
}
;
// debugger
let res = bodavm.memory.HTMLAnchorElement['href'].toString();
console.log_copy(`HTMLAnchorElement_toString `, `res ->${res}`);
return res;
};
bodavm.envFunc.Document_hidden_get = function () {
if (bodavm.config.isdebug) {
debugger;
}
;
let res = bodavm.memory.document['hidden'];
console.log_copy(`Document_hidden_get `, `res ->${res} ,未完善,可以监听visibilitychange事件来捕获文档的可见性变化`);
return res;
};
bodavm.envFunc.IDBRequest_onsuccess_set = function IDBRequest_onsuccess_set() {
if (bodavm.config.isdebug) {
debugger;
}
;
let onsuccess = arguments[0];
bodavm.memory.IDBRequest['onsuccess'] = onsuccess;
console.log_copy(`IDBRequest_onsuccess_set `, `${onsuccess} `, `!!!!!!!!!未完善!!!!!!!!!!!! `);
if (bodavm.config.isdebug) {
debugger;
}
return onsuccess;
};
bodavm.envFunc.IDBRequest_onsuccess_get = function IDBRequest_onsuccess_get() {
if (bodavm.config.isdebug) {
debugger;
}
;
let onsuccess = bodavm.memory.IDBRequest['onsuccess'] ? bodavm.memory.IDBRequest['onsuccess'] : undefined;
console.log_copy(`IDBRequest_onsuccess_get `, `${onsuccess} `, `!!!!!!!!!未完善!!!!!!!!!!!! `);
if (bodavm.config.isdebug) {
debugger;
}
return onsuccess;
};
bodavm.envFunc.IDBRequest_onerror_get = function IDBRequest_onerror_get() {
if (bodavm.config.isdebug) {
debugger;
}
;
let onerror = bodavm.memory.IDBRequest['onerror'] ? bodavm.memory.IDBRequest['onerror'] : undefined;
console.log_copy(`IDBRequest_onerror_get `, `${onerror} `, `!!!!!!!!!未完善!!!!!!!!!!!! `);
if (bodavm.config.isdebug) {
debugger;
}
return onerror;
};
bodavm.envFunc.IDBOpenDBRequest_onupgradeneeded_set = function IDBOpenDBRequest_onupgradeneeded_set() {
if (bodavm.config.isdebug) {
debugger;
}
;
let onupgradeneeded = arguments[0];
bodavm.memory.IDBOpenDBRequest['onupgradeneeded'] = onupgradeneeded;
console.log_copy(`IDBOpenDBRequest_onupgradeneeded_set `, `${onupgradeneeded} `, `!!!!!!!!!未完善!!!!!!!!!!!! `);
if (bodavm.config.isdebug) {
debugger;
}
return onupgradeneeded;
};
bodavm.envFunc.IDBRequest_onerror_set = function IDBRequest_onerror_set() {
if (bodavm.config.isdebug) {
debugger;
}
;
let onerror = arguments[0];
bodavm.memory.IDBRequest['onerror'] = onerror;
console.log_copy(`IDBRequest_onerror_set `, `${onerror} `, `!!!!!!!!!未完善!!!!!!!!!!!! `);
if (bodavm.config.isdebug) {
debugger;
}
return onerror;
};
bodavm.envFunc.IDBFactory_open = function () {
if (bodavm.config.isdebug) {
debugger;
}
;
let name = arguments[0];
let version = arguments[1];
let DB = new IDBOpenDBRequest("bobo");
if (bodavm.config.isdebug) {
debugger;
}
console.log_copy(`IDBFactory_open `, `name->${name} `, `version->${version} ->`, `res ->`, DB);
return DB;
};
bodavm.envFunc.Node_parentNode_get = function () {
if (bodavm.config.isdebug) {
debugger;
}
;
// debugger 缺少条件判断
if (bodavm.memory.cache["Node_parentNode_get"]['this'] == this) {
let cacheValue = bodavm.memory.cache["Node_parentNode_get"]['res'];
console.log_copy(`Node_parentNode_get 已存在,直接从cache中取值`, 'res- >', cacheValue);
return cacheValue;
}
let thisNode = bodavm.toolsFunc.getProtoAttr(this) ? bodavm.toolsFunc.getProtoAttr(this) : bodavm.toolsFunc.getProtoAttr.call(this, this);
// debugger
if (thisNode.name == 'html') {
console.log_copy(this, `-> Node_parentNode_get `, 'res- > document');
return document
}
let parentNode = boda$(thisNode).parent()[0]
let isliveNode=bodavm.toolsFunc.getProtoAttr.call(parentNode,parentNode)
let newNode=null
if (isliveNode){
newNode=isliveNode
}else{
newNode = bodavm.toolsFunc.setProto(parentNode.name);
bodavm.toolsFunc.setProtoAttr.call(parentNode,parentNode,newNode)
}
bodavm.memory.cache["Node_parentNode_get"]['res'] = newNode;
bodavm.memory.cache["Node_parentNode_get"]['this'] = this;
// bodavm.memory.cache["Node_parentNode_get"]['ele'] = this;
bodavm.toolsFunc.setProtoAttr.call(newNode, newNode, parentNode);
console.log_copy(`Node_parentNode_get res->`, newNode);
return newNode;
};
bodavm.envFunc.Document_head_get = function () {
if (bodavm.config.isdebug) {
debugger;
}
;
if (bodavm.memory.cache['Document_head_get']['res']) {
console.log_copy(`Document_head_get -> `, `res -> cache中获取`);
return bodavm.memory.cache['Document_head_get']['res']
}
let _head = null
if (bodavm.memory.domDocument['head']) {
_head = boda$('head')
}
// let head =chiero('head');
if (_head) {
let headValue = new HTMLHeadElement('bobo');
bodavm.toolsFunc.setProtoAttr.call(headValue, headValue, _head);
bodavm.memory.cache['Document_head_get']['res'] = headValue;
console.log_copy(`Document_head_get -> `, `res -> `, headValue);
return headValue;
} else {
console.log_copy(`Document_head_get 结果为null 需要注意!!!!!`);
}
};
bodavm.envFunc.Document_body_get = function () {
if (bodavm.config.isdebug) {
debugger;
}
;
// debugger
let domParserbody = bodavm.memory.domDocument['body']
if (!domParserbody) {
console.log_copy(`Document_body_get ->`, `res->`, null);
return null;
}
if (bodavm.memory.cache['Document_body_get']['res']) {
// console.log_copy(`Document_body_get 已存在缓存,直接获取`);
return bodavm.memory.cache['Document_body_get']['res'];
}
// let body = {}
// body.__proto__ = HTMLBodyElement.prototype;
let body = new HTMLBodyElement('bobo');
domParserbody = bodavm.memory.domDocument['body'][0]
bodavm.toolsFunc.setProtoAttr.call(body, body, domParserbody);
// bodavm.memory.cache['Document_body_get']['this'] = this;
bodavm.memory.cache['Document_body_get']['res'] = body;
// bodavm.memory.cache['Document_body_get']['domParserbody'] = domParserbody;
console.log_copy(`Document_body_get ->`, `res->`, body);
return body;
};
bodavm.envFunc.Document_createElement = function () {
if (bodavm.config.isdebug) {
debugger;
}
;
let arg = arguments[0];
// res={}
if (typeof arg !== 'string') {
return bodavm.toolsFunc.throwError('DOMException', `Failed to execute 'createElement' on 'Document': The tag name provided ('${arguments[0]}') is not a valid name.`)
}
let res = bodavm.toolsFunc.setProto(arg);
let ele = ''
switch (arg.toLowerCase()) {
case "audio":
ele = boda$('')
break;
case 'video':
ele = boda$('')
break
case "iframe":
ele = boda$('')
// debugger
break
case "fake":
ele = boda$('')
break
case "canvas":
ele = boda$('