In CSSSelectorParser::consumeRelativeScopeSelector we sometimes insert a PseudoClassType::RelativeScope pseudo-class at the front of the selector argument of a :has(). This is what ensures that the matching of the selector argument does not break out of the :has scope. But we only do this if (a) we don't already mention :scope in the selector argument, or (b) the :has() scope combinator is not DescendantSpace. But we do need this synthesized RelativeScope pseudo-class, otherwise this will alert true when it shouldn't: <div id=x><span></span></div> <script> alert(x.matches(":has(:scope span)")); </div>
<rdar://problem/115158183>
:scope checks for the scope element, which is different from the :has() scope element.
Pull request: https://github.com/WebKit/WebKit/pull/17579
Committed 267809@main (ae0d407eae25): <https://commits.webkit.org/267809@main> Reviewed commits have been landed. Closing PR #17579 and removing active labels.