Skip to content

[cssom] spec for inserting @import rules should explain effects on child stylesheet lists, etc. #4821

Description

@dbaron

The spec for inserting a CSS rule specifies how the rule gets inserted into a style sheet. It seems like the rule being inserted can be an @import rule, which seems like it should lead to loading of a CSS style sheet (linked from the CSSImportRules styleSheet property) and population of the CSSStyleSheet object that is being imported.

It seems like this should probably be specified in a bit more detail. In particular, given that the spec says:

Note: An @import at-rule always has an associated CSS style sheet.

it seems like what happens is that the linked CSSStyleSheet is created immediately, but gets populated later as the style sheet loads.

Some points that aren't clear are:

  • does that CSSStyleSheet get populated immediately when the newly-loaded style sheet is parsed (and then essentially follow this algorithm for adding rules recursively), or does it wait for other subresources of that style sheet to load?
  • when do relayouts happen as multiple style sheets load?

It also seems that it would be useful for this to be specified better because a number of other specifications, in particular CSS Modules (which we got here from w3ctag/design-reviews#405) and Constructible Stylesheets (w3ctag/design-reviews#308, #3433) are disallowing @import rules, a restriction that seems likely to stick around if it's done initially, and which we feel may not really be there for good underlying reasons (and may be related to the lack of solid specification here).

Metadata

Metadata

Assignees

No one assigned

    Labels

    cssom-1Current Worktag-trackerGroup bringing to attention of the TAG, or tracked by the TAG but not needing response.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions