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

Allow <div> around each <dt><dd> group in <dl> #1945

Merged
merged 7 commits into from
Oct 31, 2016
Merged

Conversation

zcorpan
Copy link
Member

@zcorpan zcorpan commented Oct 21, 2016

This only changes the content model and the rules for determining
what a dl element represents.

Fixes #1937.

This only changes the content model and the rules for determining
what a dl element represents.

Fixes #1937.
@zcorpan zcorpan added document conformance needs tests Moving the issue forward requires someone to write tests labels Oct 21, 2016
zcorpan added a commit to web-platform-tests/wpt that referenced this pull request Oct 21, 2016
@zcorpan zcorpan removed the needs tests Moving the issue forward requires someone to write tests label Oct 21, 2016
@@ -17960,6 +17991,7 @@ first matching case):&lt;/p&gt;
<dd>None.</dd>
Copy link
Member

Choose a reason for hiding this comment

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

Does div need its "contexts in which this element can be used" updated?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@@ -18344,7 +18377,8 @@ included with Exhibit B.
<dt><span data-x="concept-element-contexts">Contexts in which this element can be used</span>:</dt>
<dd>Where <span>flow content</span> is expected.</dd>
<dt><span data-x="concept-element-content-model">Content model</span>:</dt>
<dd><span>Flow content</span>.</dd>
<dd>If the element is a child of a <code>dl</code> element: one or more <code>dt</code> elements followed by one or more <code>dd</code> elements, optionally intermixed with <span>script-supporting elements</span>.</dd>
<dd>If the element is not a child of a <code>dl</code> element: <span>Flow content</span>.</dd>
<dt><span data-x="concept-element-attributes">Content attributes</span>:</dt>
<dd><span>Global attributes</span></dd>
<dt><span data-x="concept-element-dom">DOM interface</span>:</dt><!--TOPIC:DOM APIs-->
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 update the short paragraph describing the div element, and the note describing it as an element of last resort?

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 updated the description, but not the note. I don't want to tweak div itself so much in this PR, that seems like a separate issue.

@domenic
Copy link
Member

domenic commented Oct 21, 2016

I guess we should also put updating the FAQ as an action item after this is merged :)

Also mention dl in the div section. Also mention div in dl's
description of the name-value groups.
<div w-nodev>

<p>If a <code>dl</code> element has no <code>dt</code> or <code>dd</code> element children, it
contains no groups.</p>
<p>If a <code>dl</code> element has no <code>dt</code> or <code>dd</code> element children, or if
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 thinking of replacing these paragraphs with an algorithm for how to get the groups of a dl element, since right now they are probably a bit confusing and not so helpful if someone wants to actually get the groups of a dl element (in an HTML scraping tool for example).

My thinking is that the algorithm should be something like this:
http://software.hixie.ch/utilities/js/live-dom-viewer/saved/4601

@zcorpan zcorpan added the do not merge yet Pull request must not be merged per rationale in comment label Oct 24, 2016
This should be editorial. Hopefully clearer and more helpful.
@zcorpan zcorpan removed the do not merge yet Pull request must not be merged per rationale in comment label Oct 24, 2016
zcorpan added a commit to zcorpan/validator that referenced this pull request Oct 25, 2016
See whatwg/html#1945

This passes the tests in web-platform-tests/wpt#4053

Note that `<dl><script></script></dl>` previously resulted in an
error; now has no errors.
&lt;div itemscope itemtype="http://schema.org/Product">
&lt;dt itemprop="name">Café ou Chocolat Liégeois&lt;/dt>
&lt;dd itemprop="offers" itemscope itemtype="http://schema.org/Offer">
&lt;span itemprop="price">3.50 €&lt;/span>
Copy link
Member Author

Choose a reason for hiding this comment

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

Use the priceCurrency property (with ISO 4217 codes e.g. "USD") instead of including ambiguous symbols such as '$' in the value.

http://schema.org/price

sideshowbarker pushed a commit to web-platform-tests/wpt that referenced this pull request Oct 31, 2016
sideshowbarker pushed a commit to validator/validator that referenced this pull request Oct 31, 2016
See whatwg/html#1945

This passes the tests in web-platform-tests/wpt#4053

Note that `<dl><script></script></dl>` previously resulted in an
error; now has no errors.
sideshowbarker pushed a commit to validator/tests that referenced this pull request Oct 31, 2016
@sideshowbarker sideshowbarker merged commit 5454d70 into master Oct 31, 2016
@sideshowbarker sideshowbarker deleted the dl-div branch October 31, 2016 08:25
@gunnarbittersmann
Copy link

Why would you want to allow div as child element of dl?
XHTML 2 had proposed a di element for that purpose: https://www.w3.org/TR/xhtml2/mod-list.html#edef_list_di. An earlier draft of HTML5 had included di as well. It has been removed later because Hixie had no use for it.
Why not introduce di now?
The problem I see with div: for not allowing any content, but just dt and dd children, another complicated if-then-else rule for its content model is needed. It would be easier with di: dl may have di, dt and dd children; di may have dt and dd children; div can stay as it was.

@annevk
Copy link
Member

annevk commented Oct 31, 2016

@gunnarbittersmann I suggest you read through #1937. Lots of alternatives were considered.

tomoyukilabs pushed a commit to tomoyukilabs/web-platform-tests that referenced this pull request Nov 7, 2016
@Marat-Tanalin
Copy link

According to the HTML5.org’s Nu Html Checker, looks like we still cannot use multiple nested DIV elements around DT/DD:

<dl>
    <div><div>
        <dt>Lorem</dt>
        <dd>Ipsum</dd>
    </div></div>
</dl>

If this is intentional (hopefully not), this is a huge limitation that makes the feature much less useful.

@zcorpan
Copy link
Member Author

zcorpan commented Jan 18, 2017

It's intentional, see #1937 (comment)

@Marat-Tanalin
Copy link

Marat-Tanalin commented Jan 18, 2017

@zcorpan Thanks, Simon. That’s a real shame. I was intending to adopt the feature, but now I’m forced to switch back to the previously used ULLIDL approach since styling often needs more than one nested element, and obviously the only purpose of allowing DIV inside DL was styling while DIV itself has no semantics.

Could you explain why exactly in practice (besides just an intent to make the content model as strict and simple as possible) using more than one DIV wrapper for DT/DD would be undesirable or impossible?

I believe there is nothing that makes this:

<dl>
    <div><div>
        <dt>Lorem</dt>
        <dd>Ipsum</dd>
    </div></div>
</dl>

less possible than this:

<dl>
    <div>
        <dt>Lorem</dt>
        <dd>Ipsum</dd>
    </div>
</dl>

(Please let me know if it’s more appropriate to discussing this in the thread you’ve referred to).

@zcorpan
Copy link
Member Author

zcorpan commented Jan 18, 2017

I was not aware of use cases that required multiple nested elements (I don't recall it being stated as a requirement in #1937), and so went with the strict and simple approach. Why do you need multiple elements? Can you point to something where you currently use ul?

Allowing arbitrary nested divs makes several things more complicated: conformance checkers, learning the language, data mining tools that get the name-value groups (the spec has an algorithm for it), as well as WYSIWYG editors wanting to support this structure.

@Marat-Tanalin
Copy link

Marat-Tanalin commented Jan 18, 2017

Why do you need multiple elements? Can you point to something where you currently use ul?

DIV is by nature a generic container free of semantics and intended solely for styling and scripting. Allowing DIV inside DL is obviously a way to overcome current shortcomings of CSS. Styling often involves using multiple nested elements to achieve the required result.

I use DL a lot, e. g. for lists of blog-post comments. Recently, I’ve implemented (not rolled-out yet) sending comments via Ajax in my blog, and planned to show each newly added comment with an animation of height smoothly increasing from zero to the actual height of the comment block including its padding. But for this to be possible, the animated block itself should not have a padding while the (only allowed) DIV in my case does have a padding (which is natural: as long as I’m now able to use DIV wrappers for DT/DD, it’s no longer reasonable to use the painful and limited workaround of applying partial styling to DT and DD instead of styling the wrapper itself). Then I’ve added another DIV specifically for the height animation, and… have discovered that’s invalid. o_O

Allowing arbitrary nested divs makes several things more complicated:
conformance checkers,

Complicating conformance checkers is probably a minor thing. And actually, complication is obviously quite little.

learning the language,

Quite the contrary, it was always possible to nest multiple DIV elements, so being unable to do this in a certain context (DL) is unexpected and confusing. Moreover, many developers will almost certainly blindly use multiple nested DIV elements inside DL with no doubt as they used to.

data mining tools that get the name-value groups (the spec has an algorithm for it), as well as WYSIWYG editors wanting to support this structure.

Given that DIV is the only allowed wrapper element between DL and DT/DD, it’s trivial and straightforward to find DT/DD by DL and vice versa regardless of how many nested wrappers are used (e. g. in JS, DL for a specific DT can be found with dt.closest('dl')).

alice pushed a commit to alice/html that referenced this pull request Jan 8, 2019
This only changes the content model and the rules for determining
what a dl element represents.

Fixes whatwg#1937.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

6 participants