Skip to content

Commit 3b5c55f

Browse files
authored
Add <style>'s disabled IDL attribute
All browsers have implemented this for a long time. (However, unlike HTMLLinkElement, no browsers implement a disabled="" content attribute for <style>.) Note that this was originally tracked by #1081. That issue was closed in #4519, though it did not spec anything <style> related.
1 parent 64d4e4d commit 3b5c55f

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

source

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3747,7 +3747,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
37473747
<li><dfn data-x="concept-css-style-sheet-media" data-x-href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-media">media</dfn></li>
37483748
<li><dfn data-x="concept-css-style-sheet-title" data-x-href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-title">title</dfn></li>
37493749
<li><dfn data-x="concept-css-style-sheet-alternate-flag" data-x-href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-alternate-flag">alternate flag</dfn></li>
3750-
<li><dfn data-x="concept-css-style-sheet-disabeld-flag" data-x-href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-disabled-flag">disabled flag</dfn></li>
3750+
<li><dfn data-x="concept-css-style-sheet-disabled-flag" data-x-href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-disabled-flag">disabled flag</dfn></li>
37513751
<li><dfn data-x="concept-css-style-sheet-CSS-rules" data-x-href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-css-rules">CSS rules</dfn></li>
37523752
<li><dfn data-x="concept-css-style-sheet-origin-clean-flag" data-x-href="https://drafts.csswg.org/cssom/#concept-css-style-sheet-origin-clean-flag">origin-clean flag</dfn></li>
37533753
</ul>
@@ -15658,6 +15658,7 @@ people expect to have work and what is necessary.
1565815658
interface <dfn interface>HTMLStyleElement</dfn> : <span>HTMLElement</span> {
1565915659
[<span>HTMLConstructor</span>] constructor();
1566015660

15661+
attribute boolean <span data-x="dom-style-disabled">disabled</span>;
1566115662
[<span>CEReactions</span>] attribute DOMString <span data-x="dom-style-media">media</span>;
1566215663
[SameObject, PutForwards=<span data-x="dom-DOMTokenList-value">value</span>] readonly attribute <span>DOMTokenList</span> <span data-x="dom-style-blocking">blocking</span>;
1566315664

@@ -15673,6 +15674,42 @@ interface <dfn interface>HTMLStyleElement</dfn> : <span>HTMLElement</span> {
1567315674
model. The element does not <span data-x="represents">represent</span> content for the
1567415675
user.</p>
1567515676

15677+
<p>The <dfn attribute for="HTMLStyleElement"><code
15678+
data-x="dom-style-disabled">disabled</code></dfn> getter steps are:</p>
15679+
15680+
<ol>
15681+
<li><p>If <span>this</span> does not have an <span>associated CSS style sheet</span>, return
15682+
false.</p></li>
15683+
15684+
<li><p>If <span>this</span>'s <span>associated CSS style sheet</span>'s <span
15685+
data-x="concept-css-style-sheet-disabled-flag">disabled flag</span> is set, return true.</p></li>
15686+
15687+
<li><p>Return false.</p></li>
15688+
</ol>
15689+
15690+
<p>The <code data-x="dom-style-disabled">disabled</code> setter steps are:</p>
15691+
15692+
<ol>
15693+
<li><p>If <span>this</span> does not have an <span>associated CSS style sheet</span>,
15694+
return.</p></li>
15695+
15696+
<li><p>If the given value is true, set <span>this</span>'s <span>associated CSS style
15697+
sheet</span>'s <span data-x="concept-css-style-sheet-disabled-flag">disabled flag</span>.
15698+
Otherwise, unset <span>this</span>'s <span>associated CSS style sheet</span>'s <span
15699+
data-x="concept-css-style-sheet-disabled-flag">disabled flag</span>.</p></li>
15700+
</ol>
15701+
15702+
<div class="example">
15703+
<p>Importantly, <code data-x="dom-style-disabled">disabled</code> attribute assignments only take
15704+
effect when the <code>style</code> element has an <span>associated CSS style sheet</span>:</p>
15705+
15706+
<pre><code class="js">const style = document.createElement('style');
15707+
style.disabled = true;
15708+
style.textContent = 'body { background-color: red; }';
15709+
document.body.append(style);
15710+
console.log(style.disabled); // false</code></pre>
15711+
</div>
15712+
1567615713
<p>The <dfn element-attr for="style"><code data-x="attr-style-media">media</code></dfn> attribute
1567715714
says which media the styles apply to. The value must be a <span>valid media query list</span>.
1567815715
<span w-nodev>The user agent must apply the styles when the <code
@@ -15799,7 +15836,7 @@ interface <dfn interface>HTMLStyleElement</dfn> : <span>HTMLElement</span> {
1579915836
<dt><span data-x="concept-css-style-sheet-owner-CSS-rule">owner CSS rule</span></dt>
1580015837
<dd><p>null</p></dd>
1580115838

15802-
<dt><span data-x="concept-css-style-sheet-disabeld-flag">disabled flag</span></dt>
15839+
<dt><span data-x="concept-css-style-sheet-disabled-flag">disabled flag</span></dt>
1580315840
<dd><p>Left at its default value.</p></dd>
1580415841

1580515842
<dt><span data-x="concept-css-style-sheet-CSS-rules">CSS rules</span></dt>
@@ -26104,7 +26141,7 @@ document.body.appendChild(wbr);</code></pre>
2610426141
<dt><span data-x="concept-css-style-sheet-owner-CSS-rule">owner CSS rule</span></dt>
2610526142
<dd><p>null</p></dd>
2610626143

26107-
<dt><span data-x="concept-css-style-sheet-disabeld-flag">disabled flag</span></dt>
26144+
<dt><span data-x="concept-css-style-sheet-disabled-flag">disabled flag</span></dt>
2610826145
<dd><p>Left at its default value.</p></dd>
2610926146

2611026147
<dt><span data-x="concept-css-style-sheet-CSS-rules">CSS rules</span></dt>

0 commit comments

Comments
 (0)