Skip to content

Commit

Permalink
First (very) draft addition of adoptedStyleSheets
Browse files Browse the repository at this point in the history
  • Loading branch information
mfreed7 authored and emilio committed Jul 20, 2021
1 parent 2ed8784 commit 3664d57
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
1 change: 1 addition & 0 deletions css-cascade-5/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,7 @@ Cascade Sorting Order</h3>
For this purpose:

<ul>
<li>Style sheets are ordered as in <a href="https://www.w3.org/TR/cssom-1/#documentorshadowroot-final-css-style-sheets">final CSS style sheets</a>.
<li>Declarations from <a at-rule lt="@import">imported style sheets</a>
are ordered as if their style sheets were substituted in place of the ''@import'' rule.
<li>Declarations from style sheets independently linked by the originating document
Expand Down
39 changes: 27 additions & 12 deletions cssom-1/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1088,19 +1088,26 @@ CSS Style Sheet Collections {#css-style-sheet-collections}
Below various new concepts are defined that are associated with each
{{DocumentOrShadowRoot}} object.

Each {{DocumentOrShadowRoot}} has an associated list of zero or more
<a>CSS style sheets</a>, named the
Each {{DocumentOrShadowRoot}} has an associated list of zero or more <a>CSS style sheets</a>, named the
<dfn export for=DocumentOrShadowRoot>document or shadow root CSS style sheets</dfn>. This is
an ordered list that contains all
<a>CSS style sheets</a> associated with the
{{DocumentOrShadowRoot}}, in
<a>tree order</a>, with
<a>CSS style sheets</a> created from HTTP
<code>Link</code> headers first, if any, in header
order.

To <dfn export>create a CSS style sheet</dfn>, run these
steps:
an ordered list that contains:
<ol>
<li>Any <a>CSS style sheets</a> created from HTTP <code>Link</code> headers, in header order</li>
<li>Any <a>CSS style sheets</a> associated with the {{DocumentOrShadowRoot}}, in <a>tree order</a></li>
</ol>

Each {{DocumentOrShadowRoot}} has an associated list of zero or more <a>CSS style sheets</a>, named the
<dfn export for=DocumentOrShadowRoot>final CSS style sheets</dfn>. This is
an ordered list that contains:
<ol>
<li>Any <a>CSS style sheets</a> created from HTTP <code>Link</code> headers, in header order</li>
<li>Any <a>CSS style sheets</a> associated with the {{DocumentOrShadowRoot}}, in <a>tree order</a></li>
<li>The contents of {{DocumentOrShadowRoot}}'s <a href="#dom-documentorshadowroot-adoptedstylesheets">adoptedStyleSheets</a>'
<a href="https://heycam.github.io/webidl/#observable-array-attribute-backing-list">backing list</a>,
in array order.</li>
</ol>

To <dfn export>create a CSS style sheet</dfn>, run these steps:

<ol>
<li>Create a new <a>CSS style sheet</a> object and set its
Expand Down Expand Up @@ -1285,12 +1292,20 @@ represented by the collection.
<pre class=idl>
partial interface mixin DocumentOrShadowRoot {
[SameObject] readonly attribute StyleSheetList styleSheets;
attribute ObservableArray&lt;CSSStyleSheet> adoptedStyleSheets;
};
</pre>

The <dfn attribute for=DocumentOrShadowRoot>styleSheets</dfn> attribute must return a {{StyleSheetList}} collection representing
the <a>document or shadow root CSS style sheets</a>.

The <a href="https://heycam.github.io/webidl/#observable-array-attribute-set-an-indexed-value">set an indexed value</a> algorithm
for <dfn attribute for="DocumentOrShadowRoot"><code>adoptedStyleSheets</code></dfn>, given <var>value</var> and <var>index</var>, is the following:
<ol>
<li>If <var>value</var>'s <a>constructed flag</a> is not set, or its <a>constructor document</a> is not equal to this
{{DocumentOrShadowRoot}}'s <a>node document</a>, throw a "{{NotAllowedError}}" {{DOMException}}.</li>
</ol>

Style Sheet Association {#style-sheet-association}
--------------------------------------------------

Expand Down

0 comments on commit 3664d57

Please sign in to comment.