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

Add create[Empty]CSSStyleSheet and bring back moreStyleSheets #33

Merged
merged 4 commits into from
Aug 29, 2018
Merged
Show file tree
Hide file tree
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
50 changes: 45 additions & 5 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Status: DREAM
ED: https://wicg.github.io/construct-stylesheets/index.html
Editor: Tab Atkins Jr., Google, http://xanthir.com/contact/
Editor: Eric Willigers, Google, ericwilligers@google.com
Editor: Rakina Zata Amni, Google, rakina@google.com
Abstract: This draft defines additions to CSSOM to make StyleSheet objects directly constructable, along with methods and APIs to make it easier to deal with stylesheets in the context of custom elements and similar.
Ignored Terms: ShadowRoot, create a medialist object, add a css style sheet, document css style sheets
</pre>
Expand All @@ -18,8 +19,9 @@ Adding Stylesheets In Script {#adding-stylesheets}
=================================

<pre class='idl'>
[Constructor(DOMString text, optional CSSStyleSheetInit options)]
partial interface CSSStyleSheet {
partial interface Document {
[NewObject] Promise&lt;CSSStyleSheet> createCSSStyleSheet(DOMString text, optional CSSStyleSheetInit options);
[NewObject] CSSStyleSheet createEmptyCSSStyleSheet(optional CSSStyleSheetInit options);
rakina marked this conversation as resolved.
Show resolved Hide resolved
};

dictionary CSSStyleSheetInit {
Expand All @@ -28,10 +30,14 @@ dictionary CSSStyleSheetInit {
boolean alternate = false;
boolean disabled = false;
};

partial interface DocumentOrShadowRoot {
attribute StyleSheetList adoptedStyleSheets;
};
</pre>

<dl>
<dt><dfn constructor for=CSSStyleSheet lt="CSSStyleSheet(text)|CSSStyleSheet(text, options)">CSSStyleSheet(text, options)</dfn></dt>
<dt><dfn method for=Document lt="createCSSStyleSheet(text)|createCSSStyleSheet(text, options)">createCSSStyleSheet(text, options)</dfn></dt>
<dd>
When called, execute these steps:

Expand All @@ -45,7 +51,7 @@ dictionary CSSStyleSheetInit {
2. If the {{CSSStyleSheetInit/media}} attribute of <var>options</var> is a string,
<a>create a MediaList object</a> from the string
and assign it as <var>sheet’s</var> media.
Otherwise, assign the value of the attribute as <var>sheet’s</var> media.
Otherwise, assign a copy of the value of the attribute as <var>sheet’s</var> media.
3. If the {{CSSStyleSheetInit/alternate}} attribute of <var>options</var> is true,
set <var>sheet’s</var> alternate flag.
4. If the {{CSSStyleSheetInit/disabled}} attribute of <var>options</var> is true,
Expand All @@ -55,7 +61,41 @@ dictionary CSSStyleSheetInit {
assign the list as <var>sheet’s</var> CSS rules;
otherwise,
set <var>sheet’s</var> CSS rules to an empty list.
6. Return <var>sheet</var>.
6. Let <var>promise</var> be a promise.
7. Wait for loading of <a spec=css-cascade-4>@import</a> rules in <var>sheet</var>.
* If any of them failed to load, reject <var>promise</var>.
* Otherwise, resolve <var>promise</var> with <var>sheet</var> once all of them have finished loading.
8. Return <var>promise</var>.
</dd>

<dt><dfn method for=Document lt="createEmptyCSSStyleSheet()|createEmptyCSSStyleSheet(options)">createEmptyCSSStyleSheet(options)</dfn></dt>
<dd>
Synchronously creates an empty CSSStyleSheet object and returns it.

When called, execute these steps:

1. Construct a new {{CSSStyleSheet}} object <var>sheet</var>,
with location set to <code>null</code>,
no parent CSS style sheet,
no owner node,
no owner CSS rule,
and a title set to the {{CSSStyleSheetInit/title}} attribute of <var>options</var>.
Set <var>sheet’s</var> origin-clean flag.
2. If the {{CSSStyleSheetInit/media}} attribute of <var>options</var> is a string,
<a>create a MediaList object</a> from the string
and assign it as <var>sheet’s</var> media.
Otherwise, assign a copy of the value of the attribute as <var>sheet’s</var> media.
3. If the {{CSSStyleSheetInit/alternate}} attribute of <var>options</var> is true,
set <var>sheet’s</var> alternate flag.
4. If the {{CSSStyleSheetInit/disabled}} attribute of <var>options</var> is true,
set <var>sheet’s</var> disabled flag.
5. Return <var>sheet</var>.
</dd>

<dt><dfn attribute for=DocumentOrShadowRoot>adoptedStyleSheets</dfn></dt>
<dd>
Style sheets assigned to this attribute are part of the <a spec=cssom-1>document CSS style sheets</a>.
They are ordered after the stylesheets in {{Document/styleSheets}}.
</dd>
</dl>

Expand Down
Loading