Skip to content

Commit

Permalink
Add activation behavior for <summary>
Browse files Browse the repository at this point in the history
Fixes #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 #2272.
  • Loading branch information
domenic authored Jan 19, 2017
1 parent 7f4bc78 commit 5e0b8e6
Showing 1 changed file with 41 additions and 4 deletions.
45 changes: 41 additions & 4 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -55325,10 +55325,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 @@ -55446,6 +55453,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>

This comment has been minimized.

Copy link
@chaals

chaals Mar 29, 2017

This step doesn't match implementations - see w3c/html#764 (comment)

This comment has been minimized.

Copy link
@annevk

annevk Mar 29, 2017

Member

Your comment there doesn't dispute this step. Did you actually test with multiple summary elements?

This comment has been minimized.

Copy link
@chaals

chaals Mar 29, 2017

Yeah, I have five tests, including one where the first summary element is the second child of details, and the second summary element is the last (4th) child. It takes the first summary element.

Tests are in http://github.com/chaals/testcases (since my tests are generally not brilliant or automated), and the relevant ones are details-* especially http://chaals.github.io/testcases/details-with-summary-middle-and-last-manual.html

This comment has been minimized.

Copy link
@annevk

annevk Mar 29, 2017

Member

Thanks, I guess @domenic should look into that.

This comment has been minimized.

Copy link
@chaals

chaals Mar 29, 2017

Sure. I'm pretty sure that just dropping this step will fix it... w3c/html@51b402a

But the spec should also qualify that only the first summary child is treated as a summary - the rest aren't interactive nor rendered as a summary...

This comment has been minimized.

Copy link
@domenic

domenic Mar 30, 2017

Author Member

@chaals, one of us must be confused. Maybe you are not testing activation behavior, but instead just clicking with the mouse, which is a different thing. The tests at web-platform-tests/wpt#4539 (particularly the cases "Should open a closed details if a span element precedes the summary" and "Should stay closed if another summary element precedes the summary") show that this step is necessary.

This comment has been minimized.

Copy link
@annevk

annevk Mar 30, 2017

Member

Clicking with the mouse should be the same. Both trigger a click event.

This comment has been minimized.

Copy link
@domenic

domenic Mar 30, 2017

Author Member

Well in this case I guess they're not, or some other confusion is going on.

This comment has been minimized.

Copy link
@annevk

annevk Mar 30, 2017

Member

So I think the problem is with the wording. If you wrote "first summary element child" it would be clearer, since "first child" is a term of art.

This comment has been minimized.

Copy link
@annevk

annevk Mar 30, 2017

Member

Reworded with #2483, thanks @chaals.

<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 @@ -72262,6 +72296,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 5e0b8e6

Please sign in to comment.