Skip to content

[css3-conditional] Should CSS.supports() accept properties which are only valid in certain rules? #5929

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

Closed
AlaskanEmily opened this issue Feb 5, 2021 · 5 comments

Comments

@AlaskanEmily
Copy link

The exact case I'm looking at is page-size ( https://drafts.csswg.org/css-page-3/#page-size-prop ), which I'm currently implementing in Firefox, and which is only specified to be valid in @page rules.

It appears that size is also valid in style declarations in WebKit in Chrome with the same syntax, which is hit in some web-platform tests, for instance https://github.com/web-platform-tests/wpt/blob/master/css/css-conditional/js/CSS-supports-CSSStyleDeclaration.html

If a property like size is supported only in a specific at-rule, should it accepted by CSS.supports?

@tabatkins
Copy link
Member

I personally believe the answer should be no, because it's possible to have a property and an at-rule descriptor of the same name, and that would be ambiguous here.

@SebastianZ
Copy link
Contributor

What @tabatkins says applies to the current syntax of property checks, though what about introducing a new syntax that includes the at-rule in the condition? I.e. something like this for example:

@supports (@page { size: 10cm; }) {
...
}

That would work like the existing parsing checks for properties and selectors, so no new logic here. It only requires to extend the syntax of @supports to take at-rules.

Sebastian

@Loirooriol
Copy link
Contributor

This is related to #2463, but discussion there is focused on a @supports variant for descriptors, while this seems more about the JS counterpart of that.

@fantasai
Copy link
Collaborator

fantasai commented Nov 9, 2021

As @tabatkins explained, there are cases where a property and descriptor have the same name, but these are nonetheless separate features: this is most evident for @font-face. For @page rules they behave almost exactly like properties, but technically this distinction still exists. I've slightly clarified the spec to say it's talking about property declarations within style rules (not descriptor declarations within at-rules). @AlaskanEmily Let me know if you think any additional clarifications are needed.

@gsnedders
Copy link
Member

It appears that size is also valid in style declarations in WebKit in Chrome with the same syntax, which is hit in some web-platform tests, for instance https://github.com/web-platform-tests/wpt/blob/master/css/css-conditional/js/CSS-supports-CSSStyleDeclaration.html

Note that this test only checks that CSSStyleDeclaration and CSS.supports agree, which per the current spec is true (both only contain properties, because we don't actually define e.g. CSSPageRule.style as having attributes for like page-size, c.f. #5649).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants