mirror of
https://github.com/smallmain/cocos-enhance-kit.git
synced 2025-10-10 20:25:23 +00:00
[adapters] 增加小游戏适配部分源码
This commit is contained in:
34
adapters/platforms/wechat/wrapper/builtin/Node.js
Normal file
34
adapters/platforms/wechat/wrapper/builtin/Node.js
Normal file
@@ -0,0 +1,34 @@
|
||||
import EventTarget from './EventTarget.js'
|
||||
|
||||
export default class Node extends EventTarget {
|
||||
constructor() {
|
||||
super()
|
||||
}
|
||||
|
||||
childNodes = []
|
||||
|
||||
appendChild(node) {
|
||||
this.childNodes.push(node)
|
||||
// if (node instanceof Node) {
|
||||
// this.childNodes.push(node)
|
||||
// } else {
|
||||
// throw new TypeError('Failed to executed \'appendChild\' on \'Node\': parameter 1 is not of type \'Node\'.')
|
||||
// }
|
||||
}
|
||||
|
||||
cloneNode() {
|
||||
const copyNode = Object.create(this)
|
||||
|
||||
Object.assign(copyNode, this)
|
||||
return copyNode
|
||||
}
|
||||
|
||||
removeChild(node) {
|
||||
const index = this.childNodes.findIndex((child) => child === node)
|
||||
|
||||
if (index > -1) {
|
||||
return this.childNodes.splice(index, 1)
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user