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 24097 - Bug in the HTML outline algorithm
Summary: Bug in the HTML outline algorithm
Status: RESOLVED FIXED
Alias: None
Product: HTML WG
Classification: Unclassified
Component: HTML5 spec (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Robin Berjon
QA Contact: HTML WG Bugzilla archive list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 24107
  Show dependency treegraph
 
Reported: 2013-12-14 19:04 UTC by Marc Hoyois
Modified: 2014-02-28 00:28 UTC (History)
5 users (show)

See Also:


Attachments

Description Marc Hoyois 2013-12-14 19:04:42 UTC
The determination of the *current section* when exiting a sectioning root is wrong and can lead to several weird behaviors, including an actual error. Here are a couple of examples.

## Example 1 (error)

<body>
<h1>A</h1>
<section></section>
<figure></figure>
<h2>B</h2>
</body>

After exiting the sectioning root <figure>, the algorithm sets the current section to be the *deepest section* in the current outline, which is the section corresponding to the <section> element. Then, when entering <h2>, it will compare the rank of <h2> with the rank of the implied heading of that section, which is undefined.

## Example 2 (no error but nonsensical outline)

<body>
<h1>A</h1>
<section><h1>B</h1></section>
<figure></figure>
<h2>C</h2>
</body>

In this case the algorithm produces the outline

1. A
   1.1. B
      1.1.1. C

If we remove the <figure> element, we get the correct outline:

1. A
   1.1. B
   1.2. C

## Solution

The problem is this: when exiting a sectioning root, the current section should be set to whichever section was current upon entering the root, but this is not always the deepest section. The algorithm could ask that the correct section be remembered, or else that section can be determined as follows (when exiting the sectioning root):

- let *current section* be the last section of the current outline
- if the last child section of *current section* exists and is an *implicit* section, then go to the step *finding the deepest child*, otherwise do nothing

## Another bug?

There is a related point which I'm not sure is intended. Consider the document:

<body>
<figure></figure>
<h1>Title</h1>
</body>

The algorithm computes the outline:

1. Untitled document
2. Title

If sectioning roots are supposed to be "invisible" in the outline, then the outline should simply be

1. Title

If the latter is indeed the intended behavior, then the algorithm should not create an implied heading when entering a sectioning root.
Comment 1 Travis Leithead [MSFT] 2014-02-28 00:28:18 UTC
EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are
satisfied with this response, please change the state of this bug to CLOSED. If
you have additional information and would like the Editor to reconsider, please
reopen this bug. If you would like to escalate the issue to the full HTML
Working Group, please add the TrackerRequest keyword to this bug, and suggest
title and text for the Tracker Issue; or you may create a Tracker Issue
yourself, if you are able to do so. For more details, see this document:


   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Accepted
Change Description: This has been fixed in WHATWG and cherry-picked into HTML5.1. As with the WHATWG bug, if this is not fixed to your satisfaction, please re-open!

https://github.com/w3c/html/commit/535fd379d54b6177e2bd846094311bb58102cac7