Skip to content
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

[css-syntax-3] Clarifications on ignored declarations #7428

Closed
cdoublev opened this issue Jun 29, 2022 · 1 comment
Closed

[css-syntax-3] Clarifications on ignored declarations #7428

cdoublev opened this issue Jun 29, 2022 · 1 comment

Comments

@cdoublev
Copy link
Collaborator

cdoublev commented Jun 29, 2022

Would it be possible to clarify wordings regarding ignored declarations, please?

Specifications defining CSS rules that accept declarations in their block value use accepts, contains, and can only contain, followed by a designation of a set of properties/descriptors. If I am not mistaken, a declaration for a property or descriptor that is not accepted must be ignored, and a rule or rule block value that does not contain a property or descriptor must ignore its declaration.

I believe that CSS Syntax provides a "general principle" for implementations to handle invalid items, which is to ignore them. But from reading this issue related to @scroll-timeline, contains and can only contains seems to imply a sensitive difference regarding forward compatibility. If I understand this matter correctly, the wordings should not imply that a declaration that cannot be contained in the CSS rule, makes this rule invalid, as with can only contain. Note that there are other specifications than Scroll Animations that currently use this wording (see references below), and do not clarify explicitly that declarations for other properties/descriptors must be ignored.

In this issue, I also demonstrate the difference in how Chrome and Firefox interprets these wordings regarding how these declarations are exposed by CSSOM. The wordings in CSS Counter Styles and CSS Fonts, which refer to an unrecognized property/descriptor or a property/descriptor value with an invalid syntax, seem to indicate that it should not be exposed. The output in Firefox would therefore be the expected one.

I think a CSS author would be confused to be able to declare then get a property via CSSStyleDeclaration, but to realize that it is ignored. But in this issue about keyframe rules, I think that a reason for exposing a non-animatable property is provided. If I understood the comments in this issue correctly, all non-animatable properties are ignored, not just the properties defined in CSS Animations.

Wording references
  • [CSS Animation 1] for a keyframe rule
    • The <declaration-list> inside of <keyframe-block> accepts any CSS property except those defined in this specification
    • The <keyframe-block> contains properties and values. The properties defined by this specification are ignored in these rules, with the exception of animation-timing-function
  • [CSS Color 5] for @color-profile
    • The @color-profile rule accepts the descriptors defined in this specification.
  • [CSS Counter Styles 3] for @counter-style
    • Any descriptors that are not recognized or implemented by a given user agent, or whose value does not match the grammars given here or in a future version of this specification, must be ignored in their entirety; they do not make the @counter-style rule invalid.
  • [CSS Fonts 4] for @font-face
    • The @font-face rule accepts the descriptors defined in this specification.
    • Like properties in a declaration block, declarations of any descriptors that are not supported by the user agent must be ignored.
  • [CSS Fonts 4] for @font-feature-values
    • The @font-feature-values block accepts <declaration-list> as its contents; these list items are either at-rules named by one of the <font-feature-value-type> at-keyword tokens, or the font-display descriptor.
  • [CSS Fonts 4] for @font-palette-values
    • The @font-palette-values rule accepts the descriptors defined in this specification.
    • Like properties in a declaration block, declarations of any descriptors that are not supported by the user agent must be ignored.
  • [CSS Page 3] for @page
    • The @page rule can only contain page properties and margin at-rules.
  • [CSS Page 3] for a margin rule
    • The margin at-rules can only contain page-margin properties.
  • [Scroll Animations 1] for @scroll-timeline
    • The <declaration-list> inside of @scroll-timeline rule can only contain the descriptors defined in this section.

@viewport in CSS Device Adaptation has not been taken into account because this specification will be rewrited.

@fantasai fantasai changed the title Clarifications on ignored declarations [css-syntax-3] Clarifications on ignored declarations Jun 30, 2022
@cdoublev
Copy link
Collaborator Author

cdoublev commented Jul 2, 2022

CSS Syntax:

For rules that use <style-block> or <declaration-list>, the spec for the rule must define which properties, descriptors, and/or at-rules are valid inside the rule; this may be as simple as saying "The @foo rule accepts the properties/descriptors defined in this specification/section.", and extension specs may simply say "The @foo rule additionally accepts the following properties/descriptors.". Any declarations or at-rules found inside the block that are not defined as valid must be removed from the rule’s value.

This means that accepts, contains, can only contain, all mean the same thing: declarations for other properties/descriptors are removed (and therefore can not be exposed by CSSOM).

@cdoublev cdoublev closed this as completed Jul 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant