W3C home > Mailing lists > Public > public-css-archive@w3.org > December 2017

Re: [csswg-drafts] [selectors4] :target-within?

From: Xidorn Quan via GitHub <sysbot+gh@w3.org>
Date: Wed, 06 Dec 2017 22:57:27 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-349802950-1512601046-sysbot+gh@w3.org>
> In this way, the shorter word `:has` would be used on the more-common thing: a fast, enumerated relational pseudo-class specifically for `:has(:focus)`, `:has(:target)`, and whatever else could be in the fast selector profile. The current slow, general relational pseudo-class would be renamed to `:has-matches(…)`.

FWIW, `:focus-within` in Gecko is currently implemented as a separate flag on all matching elements which is added or removed accordingly when focus changes.

What I want to say is that, the implementation of `:focus-within`, at least in Gecko, is not in a general enough way that can be applied to whatever pseudo-class you can find. The same approach may be applied to other single target pseudo-classes (e.g. `:target`), but it's definitely expensive for pseudo-classes which can have multiple matches, like `:link`, `:enabled`, etc.

Also we are always lack of room for more flags to track on elements, which means we may need to pay tradeoffs when adding any new flag, and thus even for single target pseudo-classes, we may want to avoid adding support for those which don't really have good use cases.

I'm not sure how other browsers implement `:focus-within`, but I would be quite interested if they can implement it with an approach which is both general and efficient.

-- 
GitHub Notification of comment by upsuper
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/457#issuecomment-349802950 using your GitHub account
Received on Wednesday, 6 December 2017 22:57:29 UTC

This archive was generated by hypermail 2.4.0 : Thursday, 24 March 2022 20:26:44 UTC