Bug 235840

Summary: [:has() pseudo-class] in combination with interactive pseudo-class can't be called twice
Product: WebKit Reporter: Jan Nicklas <j.nicklas>
Component: CSSAssignee: Nobody <webkit-unassigned>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: koivisto, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari Technology Preview   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Video of the Bug none

Description Jan Nicklas 2022-01-28 15:46:49 PST
Created attachment 450282 [details]
Video of the Bug

In Safari Technology Preview 139 the :has() selector does not seem to match correctly 
if the argument is an interactive pseudo-class with the universal selector e.g. :has(*:focus) 
and is used twice or more times.

In the following example the form should receive a red border once an input has focus:

<style>
form:has(:focus) {
  background: rgb(255, 246, 167);
}
form:has(:focus):has(input:not(:focus)){
  border: 1px solid red;
}
</style>

  <form>
    <input> 
    <input>  
</form>

I attached a video of the behaviour.
Comment 1 Radar WebKit Bug Importer 2022-02-04 15:47:18 PST
<rdar://problem/88512104>
Comment 2 Antti Koivisto 2022-02-04 22:48:37 PST
Works correctly with trunk (in form:has(:focus):has(input:not(:focus) the latter :has always matches since there is always an unfocused input in this tree). I think this was fixed after STP 139, maybe in bug 234842.

*** This bug has been marked as a duplicate of bug 234842 ***