[csswg-drafts] [cssom] CSSImportRule.media should be nullable, maybe? Difference between Chromium and Firefox (#12063)

AtkinsSJ has just created a new issue for https://github.com/w3c/csswg-drafts:

== [cssom] CSSImportRule.media should be nullable, maybe? Difference between Chromium and Firefox ==
The question here is what should be printed from this sample:

```html
<!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](https://drafts.csswg.org/cssom/#dom-stylesheet-media) attribute of the associated [CSS style sheet](https://drafts.csswg.org/cssom/#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](https://drafts.csswg.org/cssom-1/#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.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/12063 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 9 April 2025 15:17:56 UTC