Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions navigator-html-injectables/src/modules/Decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,12 @@ class DecorationGroup {
// The common ancestor is an element that definitely cannot be highlighted
this.notTextFlag?.set(id, true);
}
if(ancestor.querySelector(cannotNativeHighlight.join(", ").toLowerCase())) {
// Contains elements that definitely cannot be highlighted as children
// Check if the range itself contains elements that cannot be highlighted
const rangeFragment = range.cloneContents();
const tempDiv = this.wnd.document.createElement('div');
tempDiv.appendChild(rangeFragment);
if(tempDiv.querySelector(cannotNativeHighlight.join(", ").toLowerCase())) {
// Range contains elements that definitely cannot be highlighted
this.notTextFlag?.set(id, true);
}
if((ancestor.textContent?.trim() || "").length === 0) {
Expand Down