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 24107 - Bug in the HTML outline algorithm
Summary: Bug in the HTML outline algorithm
Status: RESOLVED DUPLICATE of bug 24100
Alias: None
Product: WHATWG
Classification: Unclassified
Component: HTML (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: Unsorted
Assignee: Ian 'Hixie' Hickson
QA Contact: contributor
URL:
Whiteboard:
Keywords:
Depends on: 24097
Blocks:
  Show dependency treegraph
 
Reported: 2013-12-16 07:54 UTC by steve faulkner
Modified: 2013-12-16 07:57 UTC (History)
4 users (show)

See Also:


Attachments

Description steve faulkner 2013-12-16 07:54:25 UTC
+++ This bug was initially created as a clone of Bug #24097 +++

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 Michael[tm] Smith 2013-12-16 07:57:51 UTC

*** This bug has been marked as a duplicate of bug 24100 ***