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).
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
@importrule, which seems like it should lead to loading of a CSS style sheet (linked from theCSSImportRulesstyleSheetproperty) and population of theCSSStyleSheetobject that is being imported.It seems like this should probably be specified in a bit more detail. In particular, given that the spec says:
it seems like what happens is that the linked
CSSStyleSheetis created immediately, but gets populated later as the style sheet loads.Some points that aren't clear are:
CSSStyleSheetget 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?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
@importrules, 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).