Skip to content

Commit b5f1663

Browse files
committed
fix(utils): childNodes compatibility
1 parent 72d65c1 commit b5f1663

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/utils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ export function containEl(
99
): boolean {
1010
let contain = false;
1111

12-
if (parentNode?.childNodes && childrenNode) {
13-
parentNode.childNodes.forEach((i) => {
14-
if (i === childrenNode) {
12+
if (parentNode?.childNodes?.length > 0 && childrenNode) {
13+
for (let i = 0; i < parentNode.childNodes.length; i++) {
14+
if (parentNode.childNodes[i] === childrenNode) {
1515
contain = true;
1616
}
17-
});
17+
}
1818
}
1919

2020
return contain;

0 commit comments

Comments
 (0)