-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
:empty
pseudo-selector (spec updated)
#180
Comments
It looks like the spec change in question was w3c/csswg-drafts@2b42b64, but were any tests written for this? If I'm reading the existing test right, which all browsers pass, the old behavior is still asserted: If that's right, it makes this an unusual case, where we in fact already have interop, but the behavior isn't what people want. |
@foolip That's correct. The current implementation (the old spec) is already interoperable, but I don't think any of the browsers support the new/revised spec. Mozilla might behind a flag, I think. And you're correct, I believe, that there are no tests for the new spec, at least none I could fine thus far. |
We added a use-counter to try to measure the impact: https://chromestatus.com/metrics/feature/timeline/popularity/2624 Looks like this is too risky to change. |
@lilles The intended use and official spec'd usage of At this point, a dev essentially has to either manually write their markup in some awful way or employ a tool to pre-uglify their code for them like Prettier (ironically) simply to prevent whitespace, so that <div
>Some content<span
>some more content</span
></div
> If this breaking change is considered too risky, I think the spec needs to be revisited and adjusted to reflect as much. At that point, a different pseudo selector would likely need to be introduced to match only non-whitespace (the current It could be named something as simple as |
It's also worth noting that for most/all of those sites listed under Sample URLs, making this change would have no impact whatsoever on their site, and |
@brandonmcconnell the risk is that a selector using The use counter is triggered in cases where the selector currently doesn't match, but would with the changes. This happens on 2.5% of page loads. That doesn't by itself prove that anything would break, but it would require additional compat analysis to ship in Blink. Often what we do is to look at a random sample of sites that trigger the use counter and try to determine if the change would be breaking, as it seems like you've done with a few cases. I agree the CSSWG should be made aware of the risk, @lilles can you file an issue? |
@foolip That's fair. I wasn't aware that the use counter was tracking for those specific instances that don't currently match but would now. In that case, I agree in that CSSWG should likely adjust the spec and move this suggested functionality to a new pseudo-selector such as |
In the State of CSS 2022 question about browser incompatibilities, there was only a single mention of (I'm commenting on all proposals where I could find some mention at all in State of CSS results.) |
In the MDN short survey on CSS & HTML, "CSS Since |
Thank you for proposing the We wanted to let you know that this proposal was not selected to be part of Interop this year. As mentioned in the comments, the spec change was deemed to be risky and warrants further discussion and resolution in the CSSWG. For an overview of our process, see the proposal selection summary. Thank you again for contributing to Interop 2023! Posted on behalf of the Interop team. |
@foolip @nairnandu Could we look into resurrecting this one for Interop 2024 as well? |
Description
:empty
pseudo-selector (spec updated to also match elements with only whitespace)Quoting the spec:
Rationale
The
:empty
pseudo-class is already widely supported among most modern browsers, but the spec has since changed to include matching for elements that contain only whitespace and no non-whitespace nodes or text nodes.Quoting the amendment to this change from the spec:
In modern web development, we have bundlers that remove all non-whitespace characters from elements, so this is not normally an issue for a good number of us, but that limits the use of features like this to those of us running non-standard tools and further gate-keeps those without them, namely JAMstack devs who may have to ensure none of their elements are ever empty, so they can target in CSS them as expected.
It's the main reason for why we tend to see HTML like this in the wild, to ensure all elements contain no unexpected whitespace:
Related discussions:
Specification
https://w3c.github.io/csswg-drafts/selectors-4/#the-empty-pseudo
Tests
The text was updated successfully, but these errors were encountered: