This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 15455 - <details> elements without a child <summary> element should automatically get one (not just a text label)
Summary: <details> elements without a child <summary> element should automatically get...
Status: RESOLVED WONTFIX
Alias: None
Product: WHATWG
Classification: Unclassified
Component: HTML (show other bugs)
Version: unspecified
Hardware: Other other
: P3 normal
Target Milestone: Unsorted
Assignee: Ian 'Hixie' Hickson
QA Contact: contributor
URL: http://www.whatwg.org/specs/web-apps/...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-08 10:35 UTC by contributor
Modified: 2012-07-18 18:48 UTC (History)
3 users (show)

See Also:


Attachments

Description contributor 2012-01-08 10:35:15 UTC
Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/interactive-elements.html
Multipage: http://www.whatwg.org/C#the-details-element
Complete: http://www.whatwg.org/c#the-details-element

Comment:
<details> elements without a child <summary> element should automatically get
one (not just a text label)

Posted from: 78.20.165.163 by mathias@qiwi.be
User agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.16 (KHTML, like Gecko) Chrome/18.0.999.0 Safari/535.16
Comment 1 Mathias Bynens 2012-01-08 10:44:55 UTC
> The first `summary` element child of the element, if any, represents the summary or legend of the
> details. If there is no child `summary` element, the user agent should provide its own legend (e.g. 
> "Details").

It would be infinitely more useful if <details> elements without a child <summary> element would automatically get a <summary> element inserted with the default text content of “Details”, rather than just a text label.

Currently it’s not possible to easily select the inserted text label in CSS or JavaScript (AFAIK) and style it or bind event handlers to it.

Changing this would make it much easier to polyfill <details>/<summary> in this case, as we could then rely on the <summary> element being there in all cases.

To clarify, what I’m proposing here is that…

    <details><p>Foo</p></details>

…generates the following DOM:

    <details>
      <summary>Details</summary>
      <p>Foo</p>
    </details>

…instead of:

    <details>
      Details
      <p>Foo</p>
    </details>
Comment 2 Mathias Bynens 2012-01-08 10:46:09 UTC
> …instead of:
> 
>     <details>
>       Details
>       <p>Foo</p>
>     </details>

Sorry, that obviously should’ve been:

    <details>
      <p>Foo</p>
    </details>
Comment 3 Ian 'Hixie' Hickson 2012-02-03 06:30:03 UTC
You're not allowed to omit the <summary>, so IMHO it doesn't really matter what happens when you omit it so long as it's the same everywhere.
Comment 4 Mathias Bynens 2012-02-03 09:18:43 UTC
(In reply to comment #3)
> You're not allowed to omit the <summary>, so IMHO it doesn't really matter what
> happens when you omit it so long as it's the same everywhere.

Well, this does make it much harder to create a polyfill that supports the case where <summary> is omitted (see comment #1). Then again, if it’s invalid to do so, I guess a polyfill probably shouldn’t bother supporting it.