Skip to content

Commit

Permalink
perf(markOthers): ignore script tags (#2913)
Browse files Browse the repository at this point in the history
  • Loading branch information
atomiks committed May 19, 2024
1 parent 197f1fd commit a50b33d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/strong-ligers-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@floating-ui/react": patch
---

perf(markOthers): avoid applying attributes to `script` tags needlessly
5 changes: 4 additions & 1 deletion packages/react/src/utils/markOthers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Modified to add conditional `aria-hidden` support:
// https://github.com/theKashey/aria-hidden/blob/9220c8f4a4fd35f63bee5510a9f41a37264382d4/src/index.ts
import {getDocument} from '@floating-ui/react/utils';
import {getNodeName} from '@floating-ui/utils/dom';

type Undo = () => void;

Expand Down Expand Up @@ -69,7 +70,9 @@ function applyAttributeToOthers(
return;
}

Array.prototype.forEach.call(parent.children, (node: Element) => {
[].forEach.call(parent.children, (node: Element) => {
if (getNodeName(node) === 'script') return;

if (elementsToKeep.has(node)) {
deep(node);
} else {
Expand Down

0 comments on commit a50b33d

Please sign in to comment.