Re: [selectors] adding a :has-focus pseudo class

On Fri, 14 Nov 2014 18:28:55 +0100, Florian Rivoal <florian@rivoal.net>  
wrote:

> ...
>
> === Conclusion ===
>
> We should add a :has-focus selector, included in the fast profile, which:
> a - matches on elements that match :focus
> b - matches on parents of elements that match :has-focus
> c - allows the host language to define additional ways in which an  
> element can match :has-focus (and then ping the whatwg to do their part)

This sounds like a good idea to me. I'm not sure the label part is  
necessary really, usually you don't focus the label, you focus the control.

The "ancestors also match" part of :active and :hover should be in the  
Selectors spec, not in HTML, but I guess that's a separate issue.

> Alternatively (and I would actually prefer that), we could add these b  
> and c rules to the existing :focus pseudo class. However, given that  
> :focus is already interoperable in not doing that, I am afraid we’d run  
> into web compat problems. Anyone has (or can gather) data to check if we  
> can do that?

It seems plausible that there are pages using :focus as a bare selector  
(or *:focus) and do not want all ancestors to get the style applied.  
Looking at webdevdata from last year, I see 295 sites out of 102,000 pages  
using bare :focus or *focus. About 99% is setting outline:0 but one is a  
menu implemented in CSS with :focus, and some also use $("*:focus") in JS  
which would return the wrong element if ancestors matched. So I think we  
shouldn't change :focus.

-- 
Simon Pieters
Opera Software

Received on Monday, 17 November 2014 09:48:55 UTC