Skip to content

[cssom] CSSImportRule.media should be nullable, maybe? Difference between Chromium and Firefox #12063

Open
@AtkinsSJ

Description

@AtkinsSJ

The question here is what should be printed from this sample:

<!doctype html>
<style>
  @import url("lol.css") supports(lol:no);
</style>
<script>
  var rule = document.styleSheets[0].cssRules[0];
  console.log(rule.media);
</script>

The IDL for this is:

https://drafts.csswg.org/cssom/#ref-for-dom-cssimportrule-href

[SameObject, PutForwards=​mediaText] readonly attribute MediaList media;

And the prose says:

The media attribute must return the value of the media attribute of the associated CSS style sheet.

However, the rule may not have an associated CSS style sheet, according to this note slightly below.

Note: An @import at-rule might not have an associated CSS style sheet (e.g., if it has a non-matching supports() condition).

In this case, it can't read the media attribute from the null style sheet, so returning null would make sense. (So, making the attribute nullable, and adjusting the prose to say to return null if no associated style sheet exists.) This is what Firefox does - however, Chromium seems to not represent an @import with a non-matching supports() clause in the CSSOM at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions