-
Notifications
You must be signed in to change notification settings - Fork 693
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
[cssom] Should getComputedStyle() support non-standard pseudo-elements? #3980
Comments
We resolved on this last year, based on the fact all browsers de-facto already allowed it to some extent at least. The discussion is saved there if you are looking for some detail in particular: |
Thank you. So the rationale was "browsers seem to allow it". The wpt PR for that change added a test for web-platform-tests/wpt#17008 tests non-standard pseudos for controls. https://wpt.fyi/results/css/css-ui/control-internal-pseudo-elements-getComputedStyle-001.html?sha=c12c73e623 shows results for Firefox and Safari. Chrome results are missing for some reason, but it passes all the tests for me. Which is to say:
|
If you could add some tests covering the previous decision, that would be awesome :-) |
Firefox also supports |
{"error": {"message": "", "code": 404}} |
I was testing unrecognized pseudo-element selectors in the context of #4456 and discovered how much of an inconsistency this issue is. Test case: https://codepen.io/AmeliaBR/pen/ZEEJeWm Summary: Chrome silently ignores invalid or unrecognized selector strings and returns the main element styles. Firefox silently returns an empty style declaration for unrecognized but valid-syntax pseudoelement selectors, which is better, but also returns the parent element results for completely invalid selectors. (Also, separate issue, but there's lots of disagreement on what to return for The current spec clearly requires a TypeError for selector-parsing errors, but doesn't give any guidance about what to do about unrecognized pseudoelement selectors that are syntactically valid. Either way, browsers clearly aren't following the TypeError expectation. Requiring errors where no one currently throws them could be bad for compat. Maybe the Firefox approach of returning zero-length style declaration objects would be better? (But make it consistent, for invalid syntax selectors, too!) |
We were discussing this in the context of #4745. It seems really unfortunate that we have divergent parsing behavior between this and querySelector. I wonder what the usage of getComputedStyle with an unsupported pseudo-element-selector is; maybe we could throw errors consistent with selectors-4 parsing? |
I think we resolved that in #2149, browsers haven't been updated though. |
What does #2149 do with unknown I would expect that: getComputedStyle(element, "::-webkit-unsupported"); would throw. |
https://drafts.csswg.org/cssom/#dom-window-getcomputedstyle
See #3968 (comment)
Why does
getComputedStyle()
support any pseudo-element? Previously it only supported::before
and::after
.This is an issue for
appearance
because UAs can support non-standard values for non-standard pseudo-elements. (Though css-ui could requireauto
to be used instead.)Do we want such pseudo-elements to be available in author CSS? Do we want to support them in
getComputedStyle()
?cc @frivoal @fantasai @FremyCompany
The text was updated successfully, but these errors were encountered: