Skip to content

Commit

Permalink
Add activation behavior for <summary>
Browse files Browse the repository at this point in the history
Fixes whatwg#2246. This also fixes the value that the open attribute is set to
to be the empty string, instead of "open", matching existing
implementations.

Tests at web-platform-tests/wpt#4539 show that
both implementers of <details> follow these same semantics, despite
there having been no spec previously. The only exception is that Blink
included a being-rendered check, but that was removed; see
https://bugs.chromium.org/p/chromium/issues/detail?id=681711.

There's still some discussion ongoing as to whether we should change the
content models to disallow interactive descendants of <summary>
elements, happening in whatwg#2272.
  • Loading branch information
domenic authored and Alice Boxhall committed Jan 7, 2019
1 parent e2897e7 commit 6724209
Showing 1 changed file with 41 additions and 4 deletions.
45 changes: 41 additions & 4 deletions source
Expand Up @@ -55327,10 +55327,17 @@ interface <dfn>HTMLDetailsElement</dfn> : <span>HTMLElement</span> {
information should be shown.</p>

<p>The user agent should allow the user to request that the additional information be shown or
hidden. To honor a request for the details to be shown, the user agent must set the <code
data-x="attr-details-open">open</code> attribute on the element to the value <code
data-x="">open</code>. To honor a request for the information to be hidden, the user agent must
remove the <code data-x="attr-details-open">open</code> attribute from the element.</p>
hidden. To honor a request for the details to be shown, the user agent must <span
data-x="concept-element-attributes-set-value">set</span> the <code
data-x="attr-details-open">open</code> attribute on the element to the empty string. To honor a
request for the information to be hidden, the user agent must <span
data-x="concept-element-attributes-remove">remove</span> the <code
data-x="attr-details-open">open</code> attribute from the element.</p>

<p class="note">This ability to request that additional information be shown or hidden may simply
be the <span>activation behavior</span> of the appropriate <code>summary</code> element, in the
case such an element exists. However, if no such element exists, user agents should 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 a task</span> that runs the
Expand Down Expand Up @@ -55448,6 +55455,33 @@ interface <dfn>HTMLDetailsElement</dfn> : <span>HTMLElement</span> {
rest of the contents of the <code>summary</code> element's parent <code>details</code>
element<span w-nodev>, if any</span>.</p>

<div w-nodev>

<p>The <span>activation behavior</span> of <code>summary</code> elements is to run the following
steps:</p>

<ol>
<li><p>If this <code>summary</code> element has no parent node, then abort these steps.</p></li>

<li><p>Let <var>parent</var> be this <code>summary</code> element's parent node.</p>

<li><p>If <var>parent</var> is not a <code>details</code> element, then abort these steps.</p>

<li><p>If <var>parent</var>'s first child <code>summary</code> element is not this
<code>summary</code> element, then abort these steps.</p></li>

<li>
<p>If the <code data-x="attr-details-open">open</code> attribute is present on
<var>parent</var>, then <span data-x="concept-element-attributes-remove">remove</span> it.
Otherwise, <span data-x="concept-element-attributes-set-value">set</span> <var>parent</var>'s
<code data-x="attr-details-open">open</code> attribute to the empty string.</p>

<p class="note">This will then run the <span>details notification task steps</span>.</p>
</li>
</ol>

</div>



<h4 id="the-menu-element">The <dfn id="menus"><code>menu</code></dfn> element</h4>
Expand Down Expand Up @@ -72277,6 +72311,9 @@ END:VCARD</pre>

<li><code>menuitem</code> elements</li>

<li><code>summary</code> elements that are the first child <code>summary</code> element of a
<code>details</code> element</li>

<li>Elements with a <code data-x="attr-draggable">draggable</code> attribute set, if that would
enable the user agent to allow the user to begin a drag operations for those elements without
the use of a pointing device</li>
Expand Down

0 comments on commit 6724209

Please sign in to comment.