File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
navigator-html-injectables/src/modules Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -103,8 +103,12 @@ class DecorationGroup {
103103 // The common ancestor is an element that definitely cannot be highlighted
104104 this . notTextFlag ?. set ( id , true ) ;
105105 }
106- if ( ancestor . querySelector ( cannotNativeHighlight . join ( ", " ) . toLowerCase ( ) ) ) {
107- // Contains elements that definitely cannot be highlighted as children
106+ // Check if the range itself contains elements that cannot be highlighted
107+ const rangeFragment = range . cloneContents ( ) ;
108+ const tempDiv = this . wnd . document . createElement ( 'div' ) ;
109+ tempDiv . appendChild ( rangeFragment ) ;
110+ if ( tempDiv . querySelector ( cannotNativeHighlight . join ( ", " ) . toLowerCase ( ) ) ) {
111+ // Range contains elements that definitely cannot be highlighted
108112 this . notTextFlag ?. set ( id , true ) ;
109113 }
110114 if ( ( ancestor . textContent ?. trim ( ) || "" ) . length === 0 ) {
You can’t perform that action at this time.
0 commit comments