Skip to content

Commit 6f7f5e6

Browse files
committed
Add readonly attribute to fieldset element
Adds a readonly content attribute to fieldset that propagates read-only state to descendant form controls that support it, mirroring how the existing disabled attribute works. Affected descendants are input elements in states that support readonly, textarea elements, and form-associated custom elements. Controls for which readonly is not meaningful (checkbox, radio, button, select) are unaffected, as is anything inside the first legend child. Introduces concept-fe-readonly parallel to concept-fe-disabled, and formReadonlyCallback on form-associated custom elements parallel to formDisabledCallback. Closes #10293
1 parent f7b4402 commit 6f7f5e6

1 file changed

Lines changed: 64 additions & 3 deletions

File tree

source

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58283,8 +58283,8 @@ interface <dfn interface>HTMLTextAreaElement</dfn> : <span>HTMLElement</span> {
5828358283

5828458284
<div algorithm>
5828558285
<p>A <code>textarea</code> element is <span data-x="concept-fe-mutable">mutable</span> if it is
58286-
neither <span data-x="concept-fe-disabled">disabled</span> nor has a <code
58287-
data-x="attr-textarea-readonly">readonly</code> attribute specified.</p>
58286+
neither <span data-x="concept-fe-disabled">disabled</span> nor <span
58287+
data-x="concept-fe-readonly">readonly</span>.</p>
5828858288
</div>
5828958289

5829058290
<div algorithm>
@@ -59479,6 +59479,7 @@ out of 233&#x2009;257&#x2009;824 bytes available&lt;/meter>&lt;/p></code></pre>
5947959479
<dt><span data-x="concept-element-attributes">Content attributes</span>:</dt>
5948059480
<dd><span>Global attributes</span></dd>
5948159481
<dd><code data-x="attr-fieldset-disabled">disabled</code></dd>
59482+
<dd><code data-x="attr-fieldset-readonly">readonly</code></dd>
5948259483
<dd><code data-x="attr-fae-form">form</code></dd>
5948359484
<dd><code data-x="attr-fe-name">name</code> <!-- variant --> </dd>
5948459485
<dt><span
@@ -59492,6 +59493,7 @@ interface <dfn interface>HTMLFieldSetElement</dfn> : <span>HTMLElement</span> {
5949259493
[<span>HTMLConstructor</span>] constructor();
5949359494

5949459495
[<span>CEReactions</span>, <span data-x="xattr-Reflect">Reflect</span>] attribute boolean <dfn attribute for="HTMLFieldSetElement" data-x="dom-fieldset-disabled">disabled</dfn>;
59496+
[<span>CEReactions</span>, <span data-x="xattr-Reflect">Reflect</span>] attribute boolean <dfn attribute for="HTMLFieldSetElement" data-x="dom-fieldset-readonly">readonly</dfn>;
5949559497
readonly attribute <span>HTMLFormElement</span>? <span data-x="dom-fae-form">form</span>;
5949659498
[<span>CEReactions</span>, <span data-x="xattr-Reflect">Reflect</span>] attribute DOMString <dfn attribute for="HTMLFieldSetElement" data-x="dom-fieldset-name">name</dfn>;
5949759499

@@ -59537,6 +59539,36 @@ interface <dfn interface>HTMLFieldSetElement</dfn> : <span>HTMLElement</span> {
5953759539
</ul>
5953859540
</div>
5953959541

59542+
<div algorithm>
59543+
<p>The <dfn element-attr for="fieldset"><code
59544+
data-x="attr-fieldset-readonly">readonly</code></dfn> attribute, when specified, causes the form
59545+
control descendants of the <code>fieldset</code> element that support being <span
59546+
data-x="concept-fe-readonly">readonly</span>, excluding those that are descendants of the
59547+
<code>fieldset</code> element's first <code>legend</code> element child, if any, to be <span
59548+
data-x="concept-fe-readonly">readonly</span>.</p>
59549+
59550+
<p class="note">Unlike <code data-x="attr-fieldset-disabled">disabled</code>, which propagates to
59551+
every form control descendant, <code data-x="attr-fieldset-readonly">readonly</code> only affects
59552+
descendants for which the concept of being read-only is meaningful: <code>input</code> elements in
59553+
states that support <code data-x="attr-input-readonly">readonly</code>, <code>textarea</code>
59554+
elements, and <span data-x="form-associated custom element">form-associated custom
59555+
elements</span>.</p>
59556+
</div>
59557+
59558+
<div algorithm>
59559+
<p>A <code>fieldset</code> element is a <dfn data-x="concept-fieldset-readonly">readonly
59560+
fieldset</dfn> if it matches any of the following conditions:</p>
59561+
59562+
<ul>
59563+
<li>Its <code data-x="attr-fieldset-readonly">readonly</code> attribute is specified
59564+
59565+
<li>It is a descendant of another <code>fieldset</code> element whose <code
59566+
data-x="attr-fieldset-readonly">readonly</code> attribute is specified, and is <em>not</em> a
59567+
descendant of that <code>fieldset</code> element's first <code>legend</code> element child, if
59568+
any.</li>
59569+
</ul>
59570+
</div>
59571+
5954059572
<p>The <code data-x="attr-fae-form">form</code> attribute is used to explicitly associate the
5954159573
<code>fieldset</code> element with its <span>form owner</span>. The <code
5954259574
data-x="attr-fe-name">name</code> attribute represents the element's name.</p>
@@ -59673,6 +59705,25 @@ interface <dfn interface>HTMLFieldSetElement</dfn> : <span>HTMLElement</span> {
5967359705

5967459706
</div>
5967559707

59708+
<div class="example">
59709+
59710+
<p>The following snippet shows a <code>fieldset</code> whose <code
59711+
data-x="attr-fieldset-readonly">readonly</code> attribute makes every text-like control inside
59712+
read-only, while leaving controls that do not support <code
59713+
data-x="attr-input-readonly">readonly</code> (such as the radio buttons) unaffected:</p>
59714+
59715+
<pre><code class="html">&lt;fieldset readonly>
59716+
&lt;legend>Shipping address&lt;/legend>
59717+
&lt;p>&lt;label>Name: &lt;input name=name value="Ada Lovelace">&lt;/label>&lt;/p>
59718+
&lt;p>&lt;label>Notes: &lt;textarea name=notes>Leave at door.&lt;/textarea>&lt;/label>&lt;/p>
59719+
&lt;p>Delivery window:
59720+
&lt;label>&lt;input type=radio name=window value=am checked> Morning&lt;/label>
59721+
&lt;label>&lt;input type=radio name=window value=pm> Afternoon&lt;/label>
59722+
&lt;/p>
59723+
&lt;/fieldset></code></pre>
59724+
59725+
</div>
59726+
5967659727

5967759728
<h4>The <dfn element><code>legend</code></dfn> element</h4>
5967859729

@@ -60438,7 +60489,6 @@ form.method === input; // => true</code></pre>
6043860489

6043960490
</div>
6044060491

60441-
6044260492
<h5>Form submission attributes</h5>
6044360493

6044460494
<p><dfn>Attributes for form submission</dfn> can be specified both on <code>form</code> elements
@@ -78396,6 +78446,11 @@ customElements.define("x-foo", class extends HTMLElement {
7839678446
data-x="">formDisabledCallback</code> is called, given the new state as an
7839778447
argument.</p></li>
7839878448

78449+
<li><p>When the <span data-x="concept-fe-readonly">readonly</span> state of a
78450+
<span>form-associated custom element</span> is changed, its <code
78451+
data-x="">formReadonlyCallback</code> is called, given the new state as an
78452+
argument.</p></li>
78453+
7839978454
<li><p>When the user agent updates a <span>form-associated custom element</span>'s value on behalf of
7840078455
a user or <span data-x="restore persisted state">as part of navigation</span>, its <code
7840178456
data-x="">formStateRestoreCallback</code> is called, given the new state and a string indicating
@@ -154812,6 +154867,11 @@ interface <dfn interface>External</dfn> {
154812154867
<code data-x="attr-textarea-readonly">textarea</code>
154813154868
<td> Whether to allow the value to be edited by the user
154814154869
<td> <span>Boolean attribute</span>
154870+
<tr>
154871+
<th> <code data-x="">readonly</code>
154872+
<td> <code data-x="attr-fieldset-readonly">fieldset</code>
154873+
<td> Whether the descendant form controls that support being read-only, except any inside <code>legend</code>, are read-only
154874+
<td> <span>Boolean attribute</span>
154815154875
<tr>
154816154876
<th> <code data-x="">readonly</code>
154817154877
<td> <span data-x="attr-face-readonly">form-associated custom elements</span>
@@ -158396,6 +158456,7 @@ INSERT INTERFACES HERE
158396158456
Tawanda Moyo, <!-- tawandamoyo on GitHub-->
158397158457
Taylor Hunt,
158398158458
Ted Mielczarek,
158459+
Teo Eterovic,
158399158460
Terence Eden, <!-- edent on GitHub -->
158400158461
Terrence Wood,
158401158462
Tetsuharu OHZEKI,

0 commit comments

Comments
 (0)