Skip to content

Commit fcafd20

Browse files
committed
Filter out unattached DOM nodes
1 parent b38f6a6 commit fcafd20

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

devdocs-macos/user-scripts/page-search.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@
7777

7878
node.innerHTML = '';
7979
node.appendChild(fragment);
80+
// FIXME
81+
// Not sure sure why, but this is also returning nodes not
82+
// attached to the document tree.
8083
return Array.from(node.querySelectorAll('mark'));
8184
};
8285
};
@@ -182,7 +185,11 @@
182185
class SearchState {
183186
constructor({ term, marks }) {
184187
this.term = term;
185-
this.marks = marks;
188+
// FIXME
189+
// For some reason, we are getting nodes that are not attached
190+
// to the document tree. Work around this issue by filtering out
191+
// nodes not attached to the tree.
192+
this.marks = marks.filter(mark => document.body.contains(mark));
186193
}
187194

188195
isCurrentTerm(term) {

0 commit comments

Comments
 (0)