Skip to content
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

Specify the rendering of <details> in more detail. #10265

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
72 changes: 50 additions & 22 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -134169,6 +134169,9 @@ input[type=image i][align=bottom i], object[align=bottom i] {

<pre><code class="css">@namespace "http://www.w3.org/1999/xhtml";

details, summary {
display: block;
}
details > summary:first-of-type {
display: list-item;
counter-increment: list-item 0;
Expand All @@ -134178,28 +134181,53 @@ details[open] > summary:first-of-type {
list-style-type: disclosure-open;
}</code></pre>

<p>The <code>details</code> element is expected to render as a <span>block box</span>. The element
is also expected to have an internal <span>shadow tree</span> with two <span
data-x="concept-slot">slots</span>. The first <span data-x="concept-slot">slot</span> is expected
to take the <code>details</code> element's first <code>summary</code> element child, if any. The
second <span data-x="concept-slot">slot</span> is expected to take the <code>details</code>
element's remaining descendants, if any.</p>

<p>The <code>details</code> element's first <code>summary</code> element child, if any, is
expected to allow the user to request the details be shown or hidden.</p>

<p>The <code>details</code> element's second <span data-x="concept-slot">slot</span> is expected
to have its <code data-x="attr-style">style</code> attribute set to "<code data-x="">display:
block; content-visibility: hidden;</code>" when the <code>details</code> element does not have an
<code data-x="attr-details-open">open</code> attribute. When it does have the <code
data-x="attr-details-open">open</code> attribute, the <code data-x="attr-style">style</code>
attribute is expected to be removed from the second <span data-x="concept-slot">slot</span>.</p>

<p class="note">Because the slots are hidden inside a shadow tree, this <code
data-x="attr-style">style</code> attribute is not directly visible to author code. Its impacts,
however, are visible. Notably, the choice of <code data-x="">content-visibility: hidden</code>
instead of, e.g., <code data-x="">display: none</code>, impacts the results of various APIs that
query layout information.</p>
<p>The <code>details</code> element is expected to have an internal <span>shadow tree</span> with
three child elements:</p>

<ol>
<li>
<p>The first child element is either a <code>link</code> or <code>style</code>
element with the following styles for the <span>default summary</span>:</p>
<pre><code class="css">:host summary {
display: list-item;
counter-increment: list-item 0;
list-style: disclosure-closed inside;
}
:host([open]) > summary {
list-style-type: disclosure-open;
}</code></pre>
</li>

<li>
<p>The second child element is a <code>slot</code> that is expected to take the
<code>details</code> element's first <code>summary</code> element child, if any. This element
has a single child <code>summary</code> element called the <dfn>default summary</dfn> which has
text content that is <span>implementation-defined</span> (and probably locale-specific).</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we recommend here that it follows from the node's language? I think that's what we do for form controls today even though it's not (yet) implemented?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This matches the current wording for the default text of submit/reset buttons and (except for "possibly" versus "probably") the text of the "Choose file" button in <input type=file>. The only wording I found that seems like what you're thinking of was the wording about presentation of dates, times, and numbers. This seems more similar to submit/reset and to the file chooser button than it it does to presentation of dates, in that it feels a bit odd to make this differ from those.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect that when we changed the wording for dates, times, and numbers, the button language was overlooked. But I guess we can sort that out in a follow-up.


<p>The <code>summary</code> element that this slot <span>represents</span> is expected to allow
the user to request the details be shown or hidden.</p>
</li>

<li>
<p>The third child element is a <code>slot</code> that is expected to take the
<code>details</code> element's remaining descendants, if any. This element has no contents.</p>

<!-- TODO: link to CSS definition when spec is ready -->
<p>This element is expected to match the '::details-content' pseudo-element.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this also be mentioned in HTML's Selectors section?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure. The one existing pseudo-element (::file-selector-button) is not currently mentioned there. It seems like it might be useful to mention the pseudo-elements in that section, but it also seems like maybe (unlike for the pseudo-classes) if we do so, perhaps the pseudo-elements part of that section should be more like an index than the location of the formal definition?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I guess that's correct. In which case maybe it's not worth it.


<p>This element is expected to have its <code data-x="attr-style">style</code> attribute set to
"<code data-x="">display: block; content-visibility: hidden;</code>" when the
<code>details</code> element does not have an <code data-x="attr-details-open">open</code>
attribute. When it does have the <code data-x="attr-details-open">open</code> attribute, the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can probably use :host > summary for parallelism with the rule below right? (or just summary?)

<code data-x="attr-style">style</code> attribute is expected to be removed.</p>

<p class="note">Because the slots are hidden inside a shadow tree, this <code
data-x="attr-style">style</code> attribute is not directly visible to author code. Its impacts,
however, are visible. Notably, the choice of <code data-x="">content-visibility: hidden</code>
instead of, e.g., <code data-x="">display: none</code>, impacts the results of various APIs that
query layout information.</p>
</li>
</ol>

<!-- https://mail.gnome.org/archives/usability/2006-June/msg00015.html -->

Expand Down