Skip to content

Commit

Permalink
Fixed a bug where an infinite loop occurred in Firefox when compareDo…
Browse files Browse the repository at this point in the history
…cumentPosition results in DOCUMENT_POSITION_DISCONNECTED.

In both Chrome and Firefox, when an element is inside a webcomponent the comparison results in DOCUMENT_POSITION_DISCONNECTED. But in Firefox the element result in DOCUMENT_POSITION_FOLLOWING too, leading to an infinite loop.
  • Loading branch information
davidetan committed Jan 5, 2025
1 parent 66f7a8a commit 6895f44
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions spine-ts/spine-webgl/src/SpineWebComponentWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1416,8 +1416,12 @@ class SpineWebComponentOverlay extends HTMLElement implements OverlayAttributes,
addWidget (widget: SpineWebComponentWidget) {
this.skeletonList.push(widget);
this.intersectionObserver?.observe(widget.getHTMLElementReference());
if (this.loaded && (this.compareDocumentPosition(widget) & Node.DOCUMENT_POSITION_FOLLOWING)) {
this.parentElement!.appendChild(this);
if (this.loaded) {
const comparison = this.compareDocumentPosition(widget);
// DOCUMENT_POSITION_DISCONNECTED is needed when a widget is inside the overlay (due to followBone)
if ((comparison & Node.DOCUMENT_POSITION_FOLLOWING) && !(comparison & Node.DOCUMENT_POSITION_DISCONNECTED)) {
this.parentElement!.appendChild(this);
}
}
}

Expand Down

0 comments on commit 6895f44

Please sign in to comment.