Skip to content

Commit

Permalink
[LA Web] Add check for HTMLElement when looking for descendant with…
Browse files Browse the repository at this point in the history
… animation. (#5749)

## Summary

This issue was found in
[Expensify](Expensify/App#37463).
`node.children` was undefined, because `node` wasn't `HTMLElement` - it
was `plaintext`. This PR introduces new check - if `node` is not
`HTMLElement`, we won't perform any action.

## Test plan

Tested on Expensify App
  • Loading branch information
m-bert committed Mar 1, 2024
1 parent 97f41cc commit be8cd78
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/reanimated2/layoutReanimation/web/domUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ function findDescendantWithExitingAnimation(
node: ReanimatedHTMLElement,
root: Node
) {
// Node could be something else than HTMLElement, for example TextNode (treated as plain text, not as HTML object),
// therefore it won't have children prop and calling Array.from(node.children) will cause error.
if (!(node instanceof HTMLElement)) {
return;
}

if (node.reanimatedDummy && node.removedAfterAnimation === undefined) {
reattachElementToAncestor(node, root);
}
Expand Down

0 comments on commit be8cd78

Please sign in to comment.