Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor constructor and replaceSync() steps so CSS modules can reference them #138

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 23 additions & 12 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -78,24 +78,30 @@ dictionary CSSStyleSheetInit {
<dd>
When called, execute these steps:

1. Construct a new {{/CSSStyleSheet}} object |sheet| with the following properties:
* <a spec=cssom>location</a> set to the <a spec=html>base URL</a> of the [=associated Document=] for the [=current global object=]
* No <a spec=cssom>parent CSS style sheet</a>.
* No <a spec=cssom>owner node</a>.
* No <a spec=cssom>owner CSS rule</a>.
* <a spec=cssom>title</a> set to the {{CSSStyleSheetInit/title}} attribute of |options|.
1. Construct a new {{/CSSStyleSheet}} object |sheet|.
2. Run the steps to <a>set up a CSSStyleSheet</a> on |sheet| given |options|.
4. Return |sheet|.
</dd>

<dt>To <dfn export>set up a CSSStyleSheet</dfn></dt> on |sheet| given {{CSSStyleSheetInit}} |options|, run these steps:
<dd>
1. Set the following properties on |sheet|:
* Set <a spec=cssom>location</a> to the <a spec=html>base URL</a> of the [=associated Document=] for the [=current global object=]
* Set <a spec=cssom>parent CSS style sheet</a> to null.
* Set <a spec=cssom>owner node</a> to null.
* Set <a spec=cssom>owner CSS rule</a> to null.
* Set <a spec=cssom>title</a> to the {{CSSStyleSheetInit/title}} attribute of |options|.
* Set <a spec=cssom>alternate flag</a> if the {{CSSStyleSheetInit/alternate}} attribute of |options| is true, otherwise unset the <a spec=cssom>alternate flag</a>.
* Set <a spec=cssom>origin-clean flag</a>.
* 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,
<a>create a MediaList object</a> from the string
and assign it as |sheet|'s <a spec=cssom>media</a>.
Otherwise, [=serialize a media query list=] from the attribute and then [=create a MediaList object=]
from the resulting string and set it as |sheet|'s <a spec=cssom>media</a>.
3. If the {{CSSStyleSheetInit/disabled}} attribute of |options| is true,
set |sheet|'s <a spec=cssom>disabled flag</a>.
4. Return |sheet|.
</dd>
</dl>

Expand Down Expand Up @@ -176,10 +182,15 @@ Note that we're explicitly monkeypatching CSSOM. We are working on [merging this
<dd>
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 <a>@import</a> rules, throw a "{{NotAllowedError}}" {{DOMException}}.
5. Set |sheet|'s [=CSS rules=] to |rules|.
2. Run the steps to <a>synchronously replace the rules of a CSSStyleSheet</a> on |sheet| given |text|.
</dd>

<dt>To <dfn export>synchronously replace the rules of a CSSStyleSheet</dfn></dt> on |sheet| given |text|, run these steps:
<dd>
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 <a>@import</a> rules, throw a "{{NotAllowedError}}" {{DOMException}}.
4. Set |sheet|'s [=CSS rules=] to |rules|.
</dd>

</dl>
Expand Down