精简模板解析

master
yutent 2023-09-20 19:08:11 +08:00
parent c5333cbc2a
commit 3908bf7fe6
2 changed files with 3 additions and 23 deletions

View File

@ -254,9 +254,6 @@ class TemplateInstance {
get parentNode() {
return this._$parent.parentNode
}
get _$isConnected() {
return this._$parent._$isConnected
}
#checkRef(node, walker, options) {
do {
@ -352,11 +349,8 @@ class ChildPart {
this._$endNode = endNode
this._$parent = parent
this.options = options
this.__isConnected = options.isConnected ?? true
}
get _$isConnected() {
return this._$parent?._$isConnected ?? this.__isConnected
}
get parentNode() {
let parentNode = this._$startNode.parentNode
let parent = this._$parent
@ -479,11 +473,6 @@ class ChildPart {
start = node
}
}
setConnected(isConnected) {
if (this._$parent === void 0) {
this.__isConnected = isConnected
}
}
}
// 常规属性
class AttributePart {
@ -505,9 +494,6 @@ class AttributePart {
get tagName() {
return this.element.tagName
}
get _$isConnected() {
return this._$parent._$isConnected
}
_$setValue(value, valueIndex) {
let strings = this.strings
@ -685,9 +671,7 @@ class ElementPart {
this._$parent = parent
this.options = options
}
get _$isConnected() {
return this._$parent._$isConnected
}
_$setValue(value) {}
}

View File

@ -259,8 +259,6 @@ export class Component extends HTMLElement {
if (this.keepAlive) {
nextTick(_ => this.deactivated())
} else {
this[__children__]?.setConnected(false)
if (!document.body?.contains(this)) {
let $events = this.$events
if ($events) {
@ -380,7 +378,6 @@ export class Component extends HTMLElement {
// 初始化时不触发updated回调
if (this[__mounted__] === false) {
this[__mounted__] = true
this[__children__].setConnected(true)
if (this.$animate?.immediate) {
this.$animate()
}
@ -405,8 +402,7 @@ export class Component extends HTMLElement {
try {
let ast = this.render()
this[__children__] = render(ast, this.root, {
host: this,
isConnected: !this[__mounted__] && this.isConnected
host: this
})
} catch (err) {
console.error(err)