Skip to content

Commit

Permalink
avoid noop insertBefore
Browse files Browse the repository at this point in the history
re-inserting in same place can disrupt composition
  • Loading branch information
jhchen committed Mar 9, 2018
1 parent d22ff1b commit 17f6123
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/blot/abstract/shadow.ts
Expand Up @@ -98,7 +98,8 @@ class ShadowBlot implements Blot {
if (refBlot != null) {
refDomNode = refBlot.domNode;
}
if (this.next == null || this.domNode.nextSibling != refDomNode) {
if (this.domNode.parentNode != parentBlot.domNode ||
this.domNode.nextSibling != refDomNode) {
parentBlot.domNode.insertBefore(this.domNode, refDomNode);
}
this.parent = parentBlot;
Expand Down

1 comment on commit 17f6123

@icewind7030
Copy link

@icewind7030 icewind7030 commented on 17f6123 Apr 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This really fixes some weird problems, could you please explain why parentNode is the better condition to determine? I debugged a lot and couldn't figure it out.

Please sign in to comment.