// DOM(文档对象模型):
// document:表示整个文档,包含网页的内容和结构。
// getElementById:通过元素的id属性获取元素节点。
// getElementsByTagName:通过元素的标签名获取元素节点集合。
// createElement:创建一个新的元素节点。
// appendChild:将一个元素节点添加到指定节点的子节点列表末尾。
// removeChild:从指定节点的子节点列表中移除一个子节点。
// innerHTML:获取或设置元素的HTML内容。
;;
(function () {
bodavm.envFunc.DOMRectList_length_get=function (){
console.log(this,` -> DOMRectList_length_get res -> 默认返回1`)
return 1
}
bodavm.envFunc.Element_getClientRects=function (){
let getClientRects=new DOMRectList('bobo')
console.log(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(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(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(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(`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(`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(`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(`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(`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(`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(`Document_ontransitioncancel_get res->`,ontransitioncancel)
return ontransitioncancel
}
bodavm.envFunc.Document_pictureInPictureEnabled_get=function (){
console.log(`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(`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(`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(`Document_featurePolicy_get cache已存在返回->`,isfeaturePolicy)
return isfeaturePolicy
}
let feature=new FeaturePolicy('boob')
console.log(`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(`Document_onmousemove_get res->`,onmousemove)
return onmousemove
}
bodavm.envFunc.HTMLElement_onmouseenter_get=function (){
let onmouseenter=bodavm.toolsFunc.getProtoAttr.call(this,'onmouseenter')
console.log(`HTMLElement_onmouseenter_get -> res -> `,onmouseenter)
return onmouseenter
}
bodavm.envFunc.Document_scrollingElement_get=function (){
let ele=document.documentElement
console.log(`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 = 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 = 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 newNode = bodavm.toolsFunc.setProto('TEXT')
bodavm.toolsFunc.setProtoAttr.call(newNode, newNode, arg)
console.log_copy(this, ` -> Document_createTextNode -> res ->`, newNode)
return newNode
}
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.collection[tagName] && bodavm.memory.cache['Document_getElementsByClassName'][tagName]['this'] == this) {
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] = []
if (classList) {
for (let ind = 0; ind < classList.length; ind++) {
let newNode = bodavm.toolsFunc.setProto(classList[ind].name)
let currNode = classList[ind]
bodavm.toolsFunc.setProtoAttr.call(newNode, newNode, currNode)
bodavm.memory.collection[tagName].push(newNode)
}
}
// debugger
bodavm.memory.collection[tagName].__proto__ = HTMLCollection.prototype
bodavm.memory.cache['Document_getElementsByClassName'][tagName]['res'] = bodavm.memory.collection[tagName]
bodavm.memory.cache['Document_getElementsByClassName'][tagName]['this'] = this
bodavm.memory.collection[tagName].__proto__[Symbol.iterator] = Array.prototype[Symbol.iterator];
console.log_copy(`Document_getElementsByClassName `, `arg ->`, tagName, ' -> res- >', bodavm.memory.collection[tagName])
// debugger
return bodavm.memory.collection[tagName];
}
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 = bodavm.toolsFunc.setProto(currentNode.name)
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 = bodavm.toolsFunc.setProto(name)
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 = bodavm.toolsFunc.setProto(node_.name)
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 = bodavm.toolsFunc.setProto(parentEle.name)
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 name = child.name ? child.name : child.type
let newNode = bodavm.toolsFunc.setProto(name)
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) {
newNode = bodavm.toolsFunc.setProto(resNode[0].name)
bodavm.toolsFunc.setProtoAttr.call(newNode, newNode, resNode[0])
}
console.log_copy(this, `-> Element_querySelector 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 targetNode = bodavm.toolsFunc.getProtoAttr.call(target, target)
let target2sNode = bodavm.toolsFunc.getProtoAttr.call(target2, target2)
// debugger
if (targetNode.name == 'script' && target2sNode.name == 'script') {
debugger
bodavm.memory.waitExec.push(targetNode)
}
boda$(target2sNode).before(targetNode)
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) {
newNode = bodavm.toolsFunc.setProto(res.name)
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 newNode = bodavm.toolsFunc.setProto(res.name)
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(`DOMRectReadOnly_top_get res-> 默认返回`, 8)
return 8
}
bodavm.envFunc.DOMRectReadOnly_bottom_get = function () {
// debugger
console.log(`DOMRectReadOnly_bottom_get res-> 默认返回`, 245.33334350585938)
return 245.33334350585938
}
bodavm.envFunc.DOMRectReadOnly_left_get = function () {
// debugger
console.log(`DOMRectReadOnly_left_get res-> 默认返回`, 8)
return 8
}
bodavm.envFunc.DOMRectReadOnly_right_get = function () {
// debugger
console.log(`DOMRectReadOnly_right_get res-> 默认返回`, 1432)
return 1432
}
bodavm.envFunc.DOMRect_height_get = function () {
// debugger
console.log(`DOMRect_height_get res-> 默认返回`, 237.33334350585938)
return 1424
}
bodavm.envFunc.DOMRect_width_get = function () {
// debugger
console.log(`DOMRect_width_get res-> 默认返回`, 1424)
return 1424
}
bodavm.envFunc.DOMRect_y_get = function () {
// debugger
console.log(`DOMRect_y_get res-> 默认返回`, 8)
return 8
}
bodavm.envFunc.DOMRect_x_get = function () {
// debugger
console.log(`DOMRect_x_get res-> 默认返回`, 8)
return 8
}
bodavm.envFunc.Element_getBoundingClientRect = function () {
let DomRect = new DOMRect('bobo')
console.log(`Element_getBoundingClientRect res->`, DomRect)
return DomRect
}
bodavm.envFunc.Element_clientTop_get = function () {
// debugger
let thisEvent = bodavm.toolsFunc.getProtoAttr.call(this, this)
console.log(`Element_clientTop_get 当前事件为 -->`, thisEvent, ` - >默认返回 0`)
return 0
}
bodavm.envFunc.Element_clientLeft_get = function () {
// debugger
let thisEvent = bodavm.toolsFunc.getProtoAttr.call(this, this)
console.log(`Element_clientLeft_get 当前事件为 -->`, thisEvent, ` - >默认返回 0`)
return 0
}
bodavm.envFunc.Element_scrollTop_get = function () {
// debugger
let thisEvent = bodavm.toolsFunc.getProtoAttr.call(this, this)
console.log(`Element_scrollTop_get 当前事件为 -->`, thisEvent, ` - >默认返回 0`)
return 0
}
bodavm.envFunc.Element_scrollLeft_get = function () {
// debugger
let thisEvent = bodavm.toolsFunc.getProtoAttr.call(this, this)
console.log(`Element_scrollLeft_get 当前事件为 -->`, thisEvent, ` - >默认返回 0`)
return 0
}
bodavm.envFunc.MouseEvent_pageY_get = function () {
// debugger
let thisEvent = bodavm.toolsFunc.getProtoAttr.call(this, this)
console.log(`MouseEvent_pageY_get 当前事件为 -->`, thisEvent, ` - >默认返回 0`)
return 0
}
bodavm.envFunc.MouseEvent_pageX_get = function () {
// debugger
let thisEvent = bodavm.toolsFunc.getProtoAttr.call(this, this)
console.log(`MouseEvent_pageX_get 当前事件为 -->`, thisEvent, ` - >默认返回 0`)
return 0
}
bodavm.envFunc.Event_target_get = function () {
// debugger
let thisEvent = bodavm.toolsFunc.getProtoAttr.call(this, this)
console.log(`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(`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')
console.log_copy(`MediaQueryList_matches_get `, `-> res ->${matches_}`);
return matches_
}
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
}
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 = bodavm.toolsFunc.setProto(child.name)
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 = bodavm.toolsFunc.setProto(tagName)
let currNode = bodavm.memory.domDocument[tagName][ind]
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_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 = bodavm.toolsFunc.setProto(tagName)
let currNode = bodavm.memory.domDocument[tagName][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_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 = 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(`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.HTMLElement_style_get = function () {
if (bodavm.config.isdebug) {
debugger;
}
;
// debugger
if (bodavm.memory.cache["HTMLElement_style_get"]['this'] == this) {
let cacheValue = bodavm.memory.cache["HTMLElement_style_get"]['res'];
return cacheValue;
}
let _style = new CSSStyleDeclaration('bobo');
let thisNode = bodavm.toolsFunc.getProtoAttr(this) ? bodavm.toolsFunc.getProtoAttr(this) : bodavm.toolsFunc.getProtoAttr.call(this, this);
bodavm.toolsFunc.setProtoAttr(_style, thisNode);
bodavm.memory.cache['HTMLElement_style_get']["res"] = _style;
bodavm.memory.cache['HTMLElement_style_get']["this"] = this;
console.log_copy(this, ` ->HTMLElement_style_get res->`, _style);
return _style;
};
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 newNode = bodavm.toolsFunc.setProto(parentNode.name);
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(`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$('