From c6051b5cc2891d15ccd660fbec0969389cd8721a Mon Sep 17 00:00:00 2001 From: Daniel Clark Date: Mon, 3 May 2021 16:38:56 -0700 Subject: [PATCH] Refactor constructor and replaceSync() so that CSS modules can reference steps --- index.bs | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/index.bs b/index.bs index f4c9988..ee6773f 100644 --- a/index.bs +++ b/index.bs @@ -78,16 +78,23 @@ dictionary CSSStyleSheetInit {
When called, execute these steps: - 1. Construct a new {{/CSSStyleSheet}} object |sheet| with the following properties: - * location set to the base URL of the [=associated Document=] for the [=current global object=] - * No parent CSS style sheet. - * No owner node. - * No owner CSS rule. - * title set to the {{CSSStyleSheetInit/title}} attribute of |options|. + 1. Construct a new {{/CSSStyleSheet}} object |sheet|. + 2. Run the steps to set up a CSSStyleSheet on |sheet| given |options|. + 4. Return |sheet|. +
+ +
To set up a CSSStyleSheet
on |sheet| given {{CSSStyleSheetInit}} |options|, run these steps: +
+ 1. Set the following properties on |sheet|: + * Set location to the base URL of the [=associated Document=] for the [=current global object=] + * Set parent CSS style sheet to null. + * Set owner node to null. + * Set owner CSS rule to null. + * Set title to the {{CSSStyleSheetInit/title}} attribute of |options|. * Set alternate flag if the {{CSSStyleSheetInit/alternate}} attribute of |options| is true, otherwise unset the alternate flag. * Set origin-clean flag. * Set [=constructed flag=]. - * [=Constructor document=] set to the [=associated Document=] for the [=current global object=]. + * Set [=Constructor document=] to the [=associated Document=] for the [=current global object=]. 2. If the {{CSSStyleSheetInit/media}} attribute of |options| is a string, create a MediaList object from the string and assign it as |sheet|'s media. @@ -95,7 +102,6 @@ dictionary CSSStyleSheetInit { from the resulting string and set it as |sheet|'s media. 3. If the {{CSSStyleSheetInit/disabled}} attribute of |options| is true, set |sheet|'s disabled flag. - 4. Return |sheet|.
@@ -176,10 +182,15 @@ Note that we're explicitly monkeypatching CSSOM. We are working on [merging this
When called, execute these steps: 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}}. - 5. Set |sheet|'s [=CSS rules=] to |rules|. + 2. Run the steps to synchronously replace the rules of a CSSStyleSheet on |sheet| given |text|. +
+ +
To synchronously replace the rules of a CSSStyleSheet
on |sheet| given |text|, run these steps: +
+ 1. If |sheet|'s [=constructed flag=] is not set, or |sheet|'s [=disallow modification flag=] is set, throw a "{{NotAllowedError}}" {{DOMException}}. + 2. 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. + 3. If |rules| contains one or more @import rules, throw a "{{NotAllowedError}}" {{DOMException}}. + 4. Set |sheet|'s [=CSS rules=] to |rules|.