Open oleedd opened 1 year ago
If you want to propose a new selector, at least explain what elements it would match?
Well, current work is Selectors Level 4, which only mentions :contains()
as an extension of JSONSelect. But OK, it was in the Nov 2001 CR of Level 3: https://www.w3.org/TR/2001/CR-css3-selectors-20011113/#content-selectors
The
:contains("foo")
pseudo-class notation represents an element whose textual contents contain the given substring. The argument of this pseudo-class can be a string (surrounded by double quotes) or a keyword.
And what is with it? Browsers don't support it.
This thread is relevant: https://lists.w3.org/Archives/Public/www-style/2012Apr/0377.html
In particular, https://lists.w3.org/Archives/Public/www-style/2012Apr/0380.html
It seems to be quite difficult to implement efficiently in the face of dynamic updates.
That's from 2012, things may have changed.
What about Chrome?
This is perfectly appropriate for use in a static query, like for querySelector()
It is what I need. And the same with :on-screen()
.
I think we should add this back to Selectors, but create a "dynamic" and "static" profile
Has it started? It is a very good idea. Because layout selectors can be in the "static" profile.
Profiles were already added in 483a3b693d7f60e504cff129b168e7667692defd. But later they were removed: ac45936684fe89c2658283c5aa0e3c401f66f207
Why removed?
Because the snapshot profile was only used by :has()
, and from https://github.com/w3c/csswg-drafts/issues/3925#issuecomment-492724267
It was pointed out nobody impl :has not even in query selection. Spec should align with reality and not say you can use it.
From that conversation:
Some features make this much harder, like contains() and especially the subject selector. It might be possible to do dynamic matching quickly, but it's a non-trivial task.
I suggest to ask the Chromium and Mozilla developers how it is for now.
What is with the
:contains()
selector? Why isn't it added? Can't find any info.