-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Add name attribute for grouping details elements into an exclusive accordion #9400
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
Changes from 5 commits
c88bbf7
8639043
cba81a3
51471c9
40c8996
5134538
8d04f03
9b76787
b7042fa
b945c9c
20490af
0c64396
65a26ed
e3ede80
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59454,6 +59454,7 @@ dictionary <dfn dictionary>FormDataEventInit</dfn> : <span>EventInit</span> { | |
| <dd>One <code>summary</code> element followed by <span>flow content</span>.</dd> | ||
| <dt><span data-x="concept-element-attributes">Content attributes</span>:</dt> | ||
| <dd><span>Global attributes</span></dd> | ||
| <dd><code data-x="attr-details-name">name</code></dd> | ||
| <dd><code data-x="attr-details-open">open</code></dd> | ||
| <dt><span | ||
| data-x="concept-element-accessibility-considerations">Accessibility considerations</span>:</dt> | ||
|
|
@@ -59465,6 +59466,7 @@ dictionary <dfn dictionary>FormDataEventInit</dfn> : <span>EventInit</span> { | |
| interface <dfn interface>HTMLDetailsElement</dfn> : <span>HTMLElement</span> { | ||
| [<span>HTMLConstructor</span>] constructor(); | ||
|
|
||
| [<span>CEReactions</span>] attribute DOMString <span data-x="dom-details-name">name</span>; | ||
| [<span>CEReactions</span>] attribute boolean <span data-x="dom-details-open">open</span>; | ||
| };</code></pre> | ||
| </dd> | ||
|
|
@@ -59485,6 +59487,11 @@ interface <dfn interface>HTMLDetailsElement</dfn> : <span>HTMLElement</span> { | |
| <p>The rest of the element's contents <span>represents</span> the additional information or | ||
| controls.</p> | ||
|
|
||
| <p>The <dfn element-attr for="details"><code data-x="attr-details-name">name</code></dfn> content | ||
| attribute gives the name of the group of related <code>details</code> elements that the element is | ||
| a member of. Opening one member of this group causes other members of the group to close. If the | ||
dbaron marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| attribute is specified, its value must not be the empty string.</p> | ||
|
|
||
| <p>The <dfn element-attr for="details"><code data-x="attr-details-open">open</code></dfn> content | ||
| attribute is a <span>boolean attribute</span>. If present, it indicates that both the summary and | ||
| the additional information is to be shown to the user. If the attribute is absent, only the | ||
|
|
@@ -59511,30 +59518,85 @@ interface <dfn interface>HTMLDetailsElement</dfn> : <span>HTMLElement</span> { | |
| exists, user agents can still provide this ability through some other user interface | ||
| affordance.</p> | ||
|
|
||
| <p>Whenever the <code data-x="attr-details-open">open</code> attribute is added to or removed from | ||
| a <code>details</code> element, the user agent must <span>queue an element task</span> on the | ||
| <span>DOM manipulation task source</span> given then <code>details</code> element that runs the | ||
| following steps, which are known as the <dfn>details notification task steps</dfn>, for this | ||
| <code>details</code> element:</p> | ||
| <p>The <dfn>details name group</dfn> that contains a <code>details</code> element <var>a</var> | ||
| also contains all the other <code>details</code> elements <var>b</var> that fulfill all of the | ||
| following conditions:</p> | ||
|
|
||
| <ul> | ||
|
|
||
dbaron marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <li>Both <var>a</var> and <var>b</var> are in the same <span>tree</span>, and the | ||
| <span>root</span> of that tree is a <code>Document</code> or a <code>ShadowRoot</code>.</li> | ||
|
|
||
| <li>They both have a <code data-x="attr-details-name">name</code> attribute, their <code | ||
| data-x="attr-details-name">name</code> attributes are not empty, and the value of <var>a</var>'s | ||
dbaron marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <code data-x="attr-details-name">name</code> attribute equals the value of <var>b</var>'s <code | ||
| data-x="attr-details-name">name</code> attribute.</li> | ||
|
|
||
| </ul> | ||
|
|
||
| <p>The following <span data-x="concept-element-attributes-change-ext">attribute change | ||
| steps</span>, given <var>element</var>, <var>localName</var>, <var>oldValue</var>, | ||
| <var>value</var>, and <var>namespace</var>, are used for all <code>details</code> elements:</p> | ||
|
|
||
| <ol> | ||
| <li><p>If <var>namespace</var> is not null, then return.</p></li> | ||
dbaron marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| <li><p>If <var>localName</var> is not <code data-x="attr-details-open">open</code>, then | ||
| return.</p></li> | ||
dbaron marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| <li> | ||
| <p>If another <span data-x="concept-task">task</span> has been <span data-x="queue an element | ||
| task">queued</span> to run the <span>details notification task steps</span> for this | ||
| <code>details</code> element, then return.</p> | ||
| <p>If one of <var>oldValue</var> or <var>value</var> is null and the other is not null, then | ||
| <span>queue an element task</span> on the <span>DOM manipulation task source</span> given the | ||
|
||
| <code>details</code> element that runs the following steps, which are known as the <dfn>details | ||
| notification task steps</dfn>, for <var>element</var>:</p> | ||
|
|
||
| <p class="note">When the <code data-x="attr-details-open">open</code> attribute is toggled | ||
| several times in succession, these steps essentially get coalesced so that only one event is | ||
| fired.</p> | ||
| <ol> | ||
| <li> | ||
| <p>If another <span data-x="concept-task">task</span> has been <span data-x="queue an | ||
| element task">queued</span> to run the <span>details notification task steps</span> for | ||
| <var>element</var>, then return.</p> | ||
|
|
||
| <p class="note">When the <code data-x="attr-details-open">open</code> attribute is toggled | ||
| several times in succession, these steps essentially get coalesced so that only one event is | ||
| fired.</p> | ||
dbaron marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </li> | ||
|
|
||
| <li><p><span data-x="concept-event-fire">Fire an event</span> named <code | ||
| data-x="event-toggle">toggle</code> at <var>element</var>.</p></li> | ||
| </ol> | ||
| </li> | ||
|
||
|
|
||
| <li><p><span data-x="concept-event-fire">Fire an event</span> named <code | ||
| data-x="event-toggle">toggle</code> at the <code>details</code> element.</p></li> | ||
| <li> | ||
| <p>If <var>oldValue</var> is null, <var>value</var> is not null, and <var>element</var> has a | ||
dbaron marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <code data-x="attr-details-name">name</code> attribute that is not empty, then:</p> | ||
|
|
||
| <ol> | ||
| <li> | ||
| <p>Let <var>groupMembers</var> be a list of elements, containing all elements in | ||
dbaron marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
dbaron marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <var>element</var>'s <span>details name group</span> except for <var>element</var>, in | ||
dbaron marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <span>tree order</span>.</p> | ||
|
|
||
| <p class="note">This is done because mutation events could be run during this algorithm, and | ||
| the mutation event listeners could change the members of the <span>details name group</span> | ||
| or the <span>tree order</span>. | ||
| </li> | ||
|
|
||
| <li> | ||
| <p><span data-x="list iterate">For each</span> element <var>otherElement</var> of | ||
| <var>groupMembers</var>:</p> | ||
| <ol> | ||
| <li><p>If the <code data-x="attr-details-open">open</code> attribute is set on | ||
dbaron marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <var>otherElement</var>, <span data-x="concept-element-attributes-remove">remove</span> the | ||
dbaron marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <code data-x="attr-details-open">open</code> attribute on <var>otherElement</var>. | ||
| </ol> | ||
| </li> | ||
| </ol> | ||
| </li> | ||
| </ol> | ||
|
|
||
| <p>The <dfn attribute for="HTMLDetailsElement"><code data-x="dom-details-open">open</code></dfn> | ||
| IDL attribute must <span>reflect</span> the <code data-x="attr-details-open">open</code> content | ||
| attribute.</p> | ||
| <p>The <dfn attribute for="HTMLDetailsElement"><code data-x="dom-details-name">name</code></dfn> | ||
| and <dfn attribute for="HTMLDetailsElement"><code data-x="dom-details-open">open</code></dfn> | ||
| IDL attributes must <span>reflect</span> the respective content attributes of the same name.</p> | ||
|
|
||
| </div> | ||
|
|
||
|
|
@@ -59611,6 +59673,32 @@ interface <dfn interface>HTMLDetailsElement</dfn> : <span>HTMLElement</span> { | |
|
|
||
| </div> | ||
|
|
||
| <div class="example"> | ||
|
|
||
dbaron marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <p>The following example shows the <code data-x="attr-details-name">name</code> attribute of the | ||
| <code>details</code> element being used to create an exclusive accordion, a set of | ||
| <code>details</code> elements where a user action to open one <code>details</code> element causes | ||
| any open <code>details</code> to close.</p> | ||
|
|
||
| <pre><code class="html"><section class="characteristics"> | ||
| <details name="frame-characteristics"> | ||
| <summary>Material</summary> | ||
| The picture frame is made of solid oak wood. | ||
| </details> | ||
| <details name="frame-characteristics"> | ||
| <summary>Size</summary> | ||
| The picture frame fits a photo 40cm tall and 30cm wide. | ||
| The frame is 45cm tall, 35cm wide, and 2cm thick. | ||
| </details> | ||
| <details name="frame-characteristics"> | ||
| <summary>Color</summary> | ||
| The picture frame is available in its natural wood | ||
| color, or with black stain. | ||
| </details> | ||
| </section></code></pre> | ||
|
|
||
| </div> | ||
|
|
||
| <div class="example"> | ||
|
|
||
| <p>Because the <code data-x="attr-details-open">open</code> attribute is added and removed | ||
|
|
@@ -129304,6 +129392,7 @@ interface <dfn interface>External</dfn> { | |
| <td><code>summary</code>*; | ||
| <span data-x="Flow content">flow</span></td> | ||
| <td><span data-x="global attributes">globals</span>; | ||
| <code data-x="attr-details-name">name</code>; | ||
| <code data-x="attr-details-open">open</code></td> | ||
| <td><code>HTMLDetailsElement</code></td> | ||
| </tr> | ||
|
|
@@ -131575,6 +131664,11 @@ interface <dfn interface>External</dfn> { | |
| <span data-x="attr-fe-name">form-associated custom elements</span> | ||
| <td> Name of the element to use for <span>form submission</span> and in the <code data-x="dom-form-elements">form.elements</code> API <!--or: Name of the element to use in the <code data-x="dom-form-elements">form.elements</code> API. --> | ||
| <td> <a href="#attribute-text">Text</a>* | ||
| <tr> | ||
| <th> <code data-x="">name</code> | ||
| <td> <code data-x="attr-details-name">details</code> | ||
| <td> Name of group of mutually-exclusive <code>details</code> elements | ||
| <td> <a href="#attribute-text">Text</a>* | ||
| <tr> | ||
| <th> <code data-x="">name</code> | ||
| <td> <code data-x="attr-form-name">form</code> | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.