From 3908bf7fe62b457645e9a04dfef26c50644af420 Mon Sep 17 00:00:00 2001 From: yutent Date: Wed, 20 Sep 2023 19:08:11 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B2=BE=E7=AE=80=E6=A8=A1=E6=9D=BF=E8=A7=A3?= =?UTF-8?q?=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/html.js | 20 ++------------------ src/index.js | 6 +----- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/src/html.js b/src/html.js index 456e557..bd805a9 100644 --- a/src/html.js +++ b/src/html.js @@ -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) {} } diff --git a/src/index.js b/src/index.js index 84b28a1..af2c50a 100644 --- a/src/index.js +++ b/src/index.js @@ -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)