From a64d23d35c14a0f14e7649ede2e24330919ee73d Mon Sep 17 00:00:00 2001 From: Zihua Li Date: Tue, 12 Jul 2022 11:01:47 +0800 Subject: [PATCH] Ignore uiNode in Parent#update Closes #98 --- src/blot/abstract/parent.ts | 2 +- test/unit/parent.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/blot/abstract/parent.ts b/src/blot/abstract/parent.ts index f94f2838..03dbdb26 100644 --- a/src/blot/abstract/parent.ts +++ b/src/blot/abstract/parent.ts @@ -361,7 +361,7 @@ class ParentBlot extends ShadowBlot implements Parent { }); addedNodes .filter((node) => { - return node.parentNode === this.domNode || node === this.uiNode; + return node.parentNode === this.domNode && node !== this.uiNode; }) .sort((a, b) => { if (a === b) { diff --git a/test/unit/parent.js b/test/unit/parent.js index 62f898be..31ba6b93 100644 --- a/test/unit/parent.js +++ b/test/unit/parent.js @@ -81,6 +81,15 @@ describe('Parent', function () { }).not.toThrowError(/\[Parchment\]/); }); + it('ignore added uiNode', function () { + this.scroll.appendChild(this.blot); + this.blot.attachUI(document.createElement('div')); + this.scroll.update(); + expect(this.scroll.domNode.innerHTML).toEqual( + '

0124

', + ); + }); + it('allowedChildren', function () { this.scroll.domNode.innerHTML = '

A

BC

D

'; this.scroll.update();