From 6cb08de4bde521734764b90426452c078e6010d5 Mon Sep 17 00:00:00 2001 From: Daniel Clark Date: Mon, 3 May 2021 13:01:40 -0700 Subject: [PATCH] Make @import behavior match CSSWG resolution. --- index.bs | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/index.bs b/index.bs index f4c9988..80cca21 100644 --- a/index.bs +++ b/index.bs @@ -131,7 +131,7 @@ Note that we're explicitly monkeypatching CSSOM. We are working on [merging this
1. Let |sheet| be this {{/CSSStyleSheet}} object. 2. If |sheet|'s [=disallow modification flag=] is set, throw a "{{NotAllowedError}}" {{DOMException}}. - 3. [=Parse a rule=] from |rule|. If the result is an @import rule and |sheet|'s [=constructed flag=] is set, or |sheet|'s [=parent CSS style sheet=]'s [=constructed flag=] is set, or that sheet's [=parent CSS style sheet=]'s [=constructed flag=] is set (and so on), throw a "{{NotAllowedError}}" {{DOMException}}. + 3. [=Parse a rule=] from |rule|. If the result is an @import rule and |sheet|'s [=constructed flag=] is set, or |sheet|'s [=parent CSS style sheet=]'s [=constructed flag=] is set, or that sheet's [=parent CSS style sheet=]'s [=constructed flag=] is set (and so on), throw a "{{SyntaxError}}" {{DOMException}}. 4. (The rest of the algorithm remains as in CSSOM)
@@ -150,24 +150,15 @@ Note that we're explicitly monkeypatching CSSOM. We are working on [merging this 4. Set |sheet|'s [=disallow modification flag=]. 5. [=In parallel=], do these steps: 1. Let |rules| be the result of running [=parse a list of rules=] from |text|. If |rules| is not a list of rules (i.e. an error occurred during parsing), set |rules| to an empty list. - 2. Wait for loading of @import rules in |rules| and any nested @imports from those rules (and so on). - * If any of them failed to load, [=terminate=] fetching of the remaining @import rules, and [=queue a task=] on the [=networking task source=] to perform the following steps: - 1. Unset |sheet|'s [=disallow modification flag=]. - 2. Reject |promise| with a "{{NetworkError}}" {{DOMException}}. - * Otherwise, once all of them have finished loading, [=queue a task=] on the [=networking task source=] to perform the following steps: - 1. Set |sheet|'s [=CSS rules=] to |rules|. - 2. Unset |sheet|'s [=disallow modification flag=]. - 3. Resolve |promise| with |sheet|. - -

- Note: Loading of @import rules should follow the rules used for fetching style sheets for @import rules of stylesheets from <link> elements, in regard to what counts as success, CSP, and Content-Type header checking. -

-

- Note: We will use the [=fetch group=] of |sheet|'s [=constructor document=]'s [=relevant settings object=] for @import rules and other (fonts, etc) loads. -

-

- Note: The rules regarding loading mentioned above are currently not specified rigorously anywhere. -

+ 2. [=list/For each=] |rule| of |rules|, if |rule| is an @import, [=list/remove=] it from |rules|. + 3. [=Queue a task=] on the [=networking task source=] to perform the following steps: + 1. Set |sheet|'s [=CSS rules=] to |rules|. + 2. Unset |sheet|'s [=disallow modification flag=]. + 3. Resolve |promise| with |sheet|. + +

+ Note: We will use the [=fetch group=] of |sheet|'s [=constructor document=]'s [=relevant settings object=] for loads such as fonts. +

6. Return |promise|. @@ -178,7 +169,7 @@ Note that we're explicitly monkeypatching CSSOM. We are working on [merging this 1. Let |sheet| be this {{/CSSStyleSheet}} object. 2. If |sheet|'s [=constructed flag=] is not set, or |sheet|'s [=disallow modification flag=] is set, throw a "{{NotAllowedError}}" {{DOMException}}. 3. Let |rules| be the result of running [=parse a list of rules=] from |text|. If |rules| is not a list of rules (i.e. an error occurred during parsing), set |rules| to an empty list. - 4. If |rules| contains one or more @import rules, throw a "{{NotAllowedError}}" {{DOMException}}. + 4. [=list/For each=] |rule| of |rules|, if |rule| is an @import, [=list/remove=] it from |rules|. 5. Set |sheet|'s [=CSS rules=] to |rules|.