From 9d1bd65216004ba3cbd4565264dbd03d1de0c99c Mon Sep 17 00:00:00 2001 From: Nikita Khovdun Date: Sat, 30 Sep 2023 05:51:03 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=81=D0=B8=D1=81=D1=82=D0=B5=D0=BC?= =?UTF-8?q?=D1=8B=20=D0=BF=D0=B0=D1=82=D1=87=D0=B8=D0=BD=D0=B3=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/index.ts | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/lib/index.ts b/src/lib/index.ts index efff516..f7dbcfc 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -251,23 +251,17 @@ export abstract class Component { } #patchNodeLevel(realNode: HTMLElement, virtualNode: HTMLElement, props: any) { + const SOFT_PATCH_NODENAMES = [`BUTTON`,`INPUT`]; if (realNode.children.length === 0 && virtualNode.children.length === 0) { if (this.isComponent(virtualNode) === true || this.isComponent(realNode) === true) { - const realNodeComponentName = realNode.getAttribute('x-component') - const virtualNodeComponentName = virtualNode.getAttribute('x-component') - if (realNodeComponentName !== virtualNodeComponentName) - this.#replaceVirtualChildren(realNode, virtualNode, props) + this.#replaceVirtualChildren(realNode, virtualNode, props) // maybe else patch update props in new version... - return + } + if (SOFT_PATCH_NODENAMES.includes(realNode.nodeName) && SOFT_PATCH_NODENAMES.includes(virtualNode.nodeName) && realNode.nodeName === virtualNode.nodeName) { + this.#softPatchNode(realNode, virtualNode, props) } console.log('JET DEBUG ### soft patch ', realNode, virtualNode) - this.#softPatchNode(realNode, virtualNode, props) - return } else if (realNode.children.length > 0 && virtualNode.children.length > 0) { - console.log('JET DEBUG ### compare ', realNode, virtualNode.children) - this.#compareChildNodes(realNode.children, virtualNode.children, realNode, props) - } else { - console.log('JET DEBUG ### hard patch ', realNode, virtualNode) this.#hardPatchNode(realNode, virtualNode, props) } }