From c5333cbc2a3c71df988d80ee6c5f66a2337895d5 Mon Sep 17 00:00:00 2001 From: yutent Date: Wed, 20 Sep 2023 19:02:34 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E4=B8=80=E4=BA=9B=E6=97=A0?= =?UTF-8?q?=E7=94=A8=E7=9A=84API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/html.js | 11 ++--------- src/index.js | 3 +-- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/html.js b/src/html.js index 1842aa3..456e557 100644 --- a/src/html.js +++ b/src/html.js @@ -248,7 +248,6 @@ class Template { class TemplateInstance { constructor(template, parent) { this._parts = [] - this._$disconnectableChildren = void 0 this._$template = template this._$parent = parent } @@ -349,15 +348,14 @@ class ChildPart { constructor(startNode, endNode, parent, options) { this.type = CHILD_PART this._$committedValue = NOTHING - this._$disconnectableChildren = void 0 this._$startNode = startNode this._$endNode = endNode this._$parent = parent this.options = options - this.__isConnected = options.isConnected || true + this.__isConnected = options.isConnected ?? true } get _$isConnected() { - return this._$parent?._$isConnected || this.__isConnected + return this._$parent?._$isConnected ?? this.__isConnected } get parentNode() { let parentNode = this._$startNode.parentNode @@ -475,8 +473,6 @@ class ChildPart { } #clear(start = this._$startNode.nextSibling, from) { - this._$notifyConnectionChanged?.call(this, false, true, from) - while (start && start !== this._$endNode) { let node = start.nextSibling start.remove() @@ -486,7 +482,6 @@ class ChildPart { setConnected(isConnected) { if (this._$parent === void 0) { this.__isConnected = isConnected - this._$notifyConnectionChanged?.call(this, isConnected) } } } @@ -495,7 +490,6 @@ class AttributePart { constructor(element, name, strings, decorates, parent, options = {}) { this.type = ATTRIBUTE_PART this._$committedValue = NOTHING - this._$disconnectableChildren = void 0 this.element = element this.name = name this.decorates = decorates @@ -688,7 +682,6 @@ class ElementPart { constructor(element, parent, options) { this.element = element this.type = ELEMENT_PART - this._$disconnectableChildren = void 0 this._$parent = parent this.options = options } diff --git a/src/index.js b/src/index.js index 895dbe3..84b28a1 100644 --- a/src/index.js +++ b/src/index.js @@ -253,8 +253,6 @@ export class Component extends HTMLElement { } this.#init() adoptStyles(this.root, this.constructor.styles) - - this[__children__]?.setConnected(true) } disconnectedCallback() { @@ -382,6 +380,7 @@ export class Component extends HTMLElement { // 初始化时不触发updated回调 if (this[__mounted__] === false) { this[__mounted__] = true + this[__children__].setConnected(true) if (this.$animate?.immediate) { this.$animate() }