Skip to content

Commit

Permalink
[bugfix/LEMS-2805-blockquote-hidden-in-explanation-on-mobile] Add a c…
Browse files Browse the repository at this point in the history
…omment to clarify "parentElement" usage.
  • Loading branch information
mark-fitzgerald committed Feb 4, 2025
1 parent ec925c8 commit cefeed6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/perseus/src/components/zoomable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ class Zoomable extends React.Component<Props, State> {
let parentNode = this._node;
let currentNode: HTMLElement | null = parentNode;
while (currentNode && currentNode.offsetWidth === 0) {
// When traversing up the DOM tree, we need to start at the "parentElement"
// because "closest()" can match the current element,
// and if it does so, then we are stuck in an infinite loop.
currentNode =
currentNode.parentElement?.closest(".perseus-renderer") ?? null;
}
Expand Down

0 comments on commit cefeed6

Please sign in to comment.