From ede7e8ba14ad441e5cbc0029a14568502d965eb8 Mon Sep 17 00:00:00 2001 From: Daniel Clark Date: Fri, 25 Jun 2021 14:07:09 -0700 Subject: [PATCH 1/4] Refactor CSSStyleSheet constructor and replaceSync to allow steps to be referenced directly from HTML spec, for use with CSS module scripts --- cssom-1/Overview.bs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/cssom-1/Overview.bs b/cssom-1/Overview.bs index 45c319e62094..8098b401c791 100644 --- a/cssom-1/Overview.bs +++ b/cssom-1/Overview.bs @@ -748,7 +748,11 @@ represents a style sheet as defined by the CSS specification. In the CSSOM a
CSSStyleSheet(options)
- When called, execute these steps: + When called, execute the steps to construct a CSSStyleSheet given options and return the result. +
+ +
To construct a CSSStyleSheet
given {{CSSStyleSheetInit}} options, run these steps: +
  1. Construct a new {{/CSSStyleSheet}} object sheet with the following properties:
      @@ -1027,14 +1031,17 @@ The replace(text) method
    • Return promise.
-The replaceSync(text) method must run the following steps: +The replaceSync(text) method must run the +steps to synchronously replace the rules of a CSSStyleSheet on this {{CSSStyleSheet}} given text. + +To synchronously replace the rules of a CSSStyleSheet on sheet given text, run these steps:
  1. If the constructed flag is not set, or the 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, remove those rules from rules. -
  4. Set CSS rules to rules. +
  5. Set sheet's CSS rules to rules.
#### Deprecated CSSStyleSheet members #### {#legacy-css-style-sheet-members} From 4248ac7eff92c89e5baf66064d8e71f61b1b4710 Mon Sep 17 00:00:00 2001 From: Daniel Clark Date: Fri, 25 Jun 2021 14:34:14 -0700 Subject: [PATCH 2/4] Move creation of the CSSStyleSheet back to the constructor. --- cssom-1/Overview.bs | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/cssom-1/Overview.bs b/cssom-1/Overview.bs index 8098b401c791..89c402769e6e 100644 --- a/cssom-1/Overview.bs +++ b/cssom-1/Overview.bs @@ -748,24 +748,28 @@ represents a style sheet as defined by the CSS specification. In the CSSOM a
CSSStyleSheet(options)
- When called, execute the steps to construct a CSSStyleSheet given options and return the result. + When called, execute these steps: +
    +
  1. Construct a new {{/CSSStyleSheet}} object sheet.
  2. +
  3. Run the steps to initialize a CSSStyleSheet on sheet given options. +
  4. Return sheet.
  5. +
-
To construct a CSSStyleSheet
given {{CSSStyleSheetInit}} options, run these steps: +
To initialize a {{/CSSStyleSheet}}
sheet given {{CSSStyleSheetInit}} options, run these steps:
    -
  1. Construct a new {{/CSSStyleSheet}} object sheet with the following properties:
  2. If the {{CSSStyleSheetInit/media}} attribute of options is a string, create a MediaList object from the string From 5334c56e76dfa4fc332ab98365b5b77831ccd560 Mon Sep 17 00:00:00 2001 From: Daniel Clark Date: Tue, 6 Jul 2021 12:03:14 -0700 Subject: [PATCH 3/4] Put the creation and initialization of CSSStyleSheet into the same set of steps. --- cssom-1/Overview.bs | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/cssom-1/Overview.bs b/cssom-1/Overview.bs index 89c402769e6e..5d71b5e0bc78 100644 --- a/cssom-1/Overview.bs +++ b/cssom-1/Overview.bs @@ -748,29 +748,23 @@ represents a style sheet as defined by the CSS specification. In the CSSOM a
    CSSStyleSheet(options)
    - When called, execute these steps: -
      -
    1. Construct a new {{/CSSStyleSheet}} object sheet.
    2. -
    3. Run the steps to initialize a CSSStyleSheet on sheet given options. -
    4. Return sheet.
    5. -
    + When called, execute the steps to create a CSSStyleSheet given options and return the result.
    -
    To initialize a {{/CSSStyleSheet}}
    sheet given {{CSSStyleSheetInit}} options, run these steps: +
    To create a {{/CSSStyleSheet}}
    given {{CSSStyleSheetInit}} options, run these steps:
      - +
    1. Construct a new {{/CSSStyleSheet}} object sheet.
    2. +
    3. Set sheet's location to the base URL of the associated Document for the current global object. +
    4. Set sheet's stylesheet base URL to the {{CSSStyleSheetInit/baseURL}} attribute value from options. +
    5. Set sheet's parent CSS style sheet to null. +
    6. Set sheet's owner node to null. +
    7. Set sheet's owner CSS rule to null. +
    8. Set sheet's title to the the empty string. +
    9. Unset sheet's alternate flag. +
    10. Set sheet's origin-clean flag. +
    11. Set sheet's constructed flag. +
    12. Set sheet's Constructor document to the associated Document for the current global object.
    13. If the {{CSSStyleSheetInit/media}} attribute of options is a string, create a MediaList object from the string and assign it as sheet's media. From 486975e8d1ff414cda588e4905f5e59ca00b5497 Mon Sep 17 00:00:00 2001 From: Daniel Clark Date: Wed, 7 Jul 2021 12:07:02 -0700 Subject: [PATCH 4/4] Rename constructor steps to 'create a constructed CSSStyleSheet --- cssom-1/Overview.bs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cssom-1/Overview.bs b/cssom-1/Overview.bs index 5d71b5e0bc78..a46f1e108869 100644 --- a/cssom-1/Overview.bs +++ b/cssom-1/Overview.bs @@ -748,10 +748,10 @@ represents a style sheet as defined by the CSS specification. In the CSSOM a
      CSSStyleSheet(options)
      - When called, execute the steps to create a CSSStyleSheet given options and return the result. + When called, execute the steps to create a constructed CSSStyleSheet given options and return the result.
      -
      To create a {{/CSSStyleSheet}}
      given {{CSSStyleSheetInit}} options, run these steps: +
      To create a constructed {{/CSSStyleSheet}}
      given {{CSSStyleSheetInit}} options, run these steps:
      1. Construct a new {{/CSSStyleSheet}} object sheet.