From 17413851f8a31bf1a7846547d6f5b74f5f2bee9c Mon Sep 17 00:00:00 2001 From: Timur Khazamov Date: Mon, 29 Nov 2021 13:46:39 +0100 Subject: [PATCH 1/2] IME fixup Fixes #1453 It's a backport of the commit 17f61235182bda64ba7535dab6ee5a68a4a807a9 for version 2.0 --- src/blot/abstract/parent.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/blot/abstract/parent.ts b/src/blot/abstract/parent.ts index 576ce494..9d159b9c 100644 --- a/src/blot/abstract/parent.ts +++ b/src/blot/abstract/parent.ts @@ -216,16 +216,16 @@ class ParentBlot extends ShadowBlot implements Parent { } let refDomNode: Node | null = null; this.children.insertBefore(childBlot, refBlot || null); - childBlot.parent = this; if (refBlot != null) { refDomNode = refBlot.domNode; } if ( - this.domNode.parentNode !== childBlot.domNode || - this.domNode.nextSibling !== refDomNode + childBlot.domNode.parentNode !== this.domNode || + childBlot.domNode.nextSibling !== refDomNode ) { this.domNode.insertBefore(childBlot.domNode, refDomNode); } + childBlot.parent = this; childBlot.attach(); } From 9845e464cd9a3dfb7c53f9465221214a55b91751 Mon Sep 17 00:00:00 2001 From: Nikita Rudenko Date: Mon, 11 Apr 2022 13:55:32 +0400 Subject: [PATCH 2/2] Obtain from registry each update cycle --- src/blot/scroll.ts | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/src/blot/scroll.ts b/src/blot/scroll.ts index a08087b2..696bf998 100644 --- a/src/blot/scroll.ts +++ b/src/blot/scroll.ts @@ -185,29 +185,31 @@ class ScrollBlot extends ParentBlot implements Root { context: { [key: string]: any } = {}, ): void { mutations = mutations || this.observer.takeRecords(); - const mutationsMap = new WeakMap(); - mutations - .map((mutation: MutationRecord) => { - const blot = this.find(mutation.target, true); - if (blot == null) { - return null; - } - if (mutationsMap.has(blot.domNode)) { - mutationsMap.get(blot.domNode).push(mutation); - return null; - } else { - mutationsMap.set(blot.domNode, [mutation]); - return blot; - } - }) - .forEach((blot: Blot | null) => { - if (blot != null && blot !== this && mutationsMap.has(blot.domNode)) { - blot.update(mutationsMap.get(blot.domNode) || [], context); - } - }); + const mutationsMap = new WeakMap(); + + mutations.reduce((result, mutation: MutationRecord) => { + const blot = this.find(mutation.target, true); + if (blot == null) { + return result; + } + + if (mutationsMap.has(blot.domNode)) { + mutationsMap.get(blot.domNode)!.push(mutation); + return result; + } + + mutationsMap.set(blot.domNode, [mutation]); + result.push(mutation.target); + return result; + }, []).forEach((node: Node) => { + const blot = this.find(node, true); + if (blot != null && blot !== this && mutationsMap.has(blot.domNode)) { + blot.update(mutationsMap.get(blot.domNode) || [], context); + } + }); context.mutationsMap = mutationsMap; if (mutationsMap.has(this.domNode)) { - super.update(mutationsMap.get(this.domNode), context); + super.update(mutationsMap.get(this.domNode)!, context); } this.optimize(mutations, context); }