← Back to release summary

@import rules in CSSStyleSheet.replace()

Category
CSS
Type
New or changed feature
Status
Removed (Chrome 84)
Intent stage
Removed

Summary

The original spec for constructable stylesheets allowed for calls to sheet.replace("@import('some.css');"). This use case is being removed - calls to replace() will throw an exception if @import rules are found in the replaced content. The CSS Working Group resolved to remove this feature on Feb 19, 2020: https://github.com/WICG/construct-stylesheets/issues/119#issuecomment-588352418. This feature was deprecated in M83, and will be removed in M84.

Motivation

There is an asymmetry between replaceSync(), which disallows @import rules, and replace(), which currently allows them. Additionally, work is underway on CSS Modules, which appear to be coalescing on also disallowing @imports for a first version, and (possibly) on a next version where @imports behave as leaves in the module tree. This would also be an asymmetry with the current replace() API. For these reasons, the CSS Working Group resolved to disallow @import in calls to replace().

Standards & signals

Docs: https://github.com/WICG/construct-stylesheets/blob/gh-pages/explainer.md

View on chromestatus.com