Skip to content

Commit

Permalink
complete first working implementation of the :has() pseudo-class
Browse files Browse the repository at this point in the history
  • Loading branch information
dperini committed Oct 14, 2024
1 parent bdb4101 commit 1a3a5c5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/nwsapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,8 @@
case 'has':
referenceElement = selector_string.split(':')[0];
expr = match[2].replace(REX.CommaGroup, ',').replace(REX.TrimSpaces, '');
source = 'if(s.match("' + referenceElement.replace(/\x22/g, '\\"') + '",e) && e.querySelector("'+ expr.replace(/\x22/g, '\\"') +'")){' + source + '}';
test = /^\s*>\s*/.test(expr) ? ':scope ' : '';
source = 'if(s.first("' + test + expr.replace(/\x22/g, '\\"') + '").parentElement===e){' + source + '}';
break;
default:
emit('\'' + selector_string + '\'' + qsInvalid);
Expand Down

0 comments on commit 1a3a5c5

Please sign in to comment.