Skip to content

[css-conditional] Should CSS.supports() accept !important in the 2nd argument? #5692

@Loirooriol

Description

@Loirooriol

According to https://drafts.csswg.org/css-conditional-3/#the-css-namespace,

  • CSS.supports(conditionText)

    1. If conditionText, parsed and evaluated as a <supports-condition>, would return true, return true.
    2. Otherwise, If conditionText, wrapped in parentheses and then parsed and evaluated as a <supports-condition>, would return true, return true.
    3. Otherwise, return false.

    Therefore, and according to [css-conditional-3] Are there issues with !important in @supports? (Is the grammar wrong?) #5559, we should have

    CSS.supports("background: green !important"); // true

    as all Chromium, WebKit and Firefox already do.

  • CSS.supports(property, value)

    1. If property is an ASCII case-insensitive match for any defined CSS property that the UA supports, and value successfully parses according to that property’s grammar, return true.
    2. Otherwise, if property is a custom property name string, return true.
    3. Otherwise, return false.

    I don't think !important is part of the property’s grammar, so I would expect

    CSS.supports("background", "green !important"); // false

    However, accepting !important in the single argument case, but rejecting it in the 2 arguments one, can seem inconsistent.

    And we don't have interoperability here: Firefox and Chromium return false, but WebKit returns true.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions