<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>24097</bug_id>
          
          <creation_ts>2013-12-14 19:04:42 +0000</creation_ts>
          <short_desc>Bug in the HTML outline algorithm</short_desc>
          <delta_ts>2014-02-28 00:28:18 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>HTML WG</product>
          <component>HTML5 spec</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>24107</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Marc Hoyois">marc.hoyois</reporter>
          <assigned_to name="Robin Berjon">robin</assigned_to>
          <cc>mike</cc>
    
    <cc>public-html-admin</cc>
    
    <cc>public-html-wg-issue-tracking</cc>
    
    <cc>robin</cc>
    
    <cc>travil</cc>
          
          <qa_contact name="HTML WG Bugzilla archive list">public-html-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>97620</commentid>
    <comment_count>0</comment_count>
    <who name="Marc Hoyois">marc.hoyois</who>
    <bug_when>2013-12-14 19:04:42 +0000</bug_when>
    <thetext>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)

&lt;body&gt;
&lt;h1&gt;A&lt;/h1&gt;
&lt;section&gt;&lt;/section&gt;
&lt;figure&gt;&lt;/figure&gt;
&lt;h2&gt;B&lt;/h2&gt;
&lt;/body&gt;

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

## Example 2 (no error but nonsensical outline)

&lt;body&gt;
&lt;h1&gt;A&lt;/h1&gt;
&lt;section&gt;&lt;h1&gt;B&lt;/h1&gt;&lt;/section&gt;
&lt;figure&gt;&lt;/figure&gt;
&lt;h2&gt;C&lt;/h2&gt;
&lt;/body&gt;

In this case the algorithm produces the outline

1. A
   1.1. B
      1.1.1. C

If we remove the &lt;figure&gt; 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&apos;m not sure is intended. Consider the document:

&lt;body&gt;
&lt;figure&gt;&lt;/figure&gt;
&lt;h1&gt;Title&lt;/h1&gt;
&lt;/body&gt;

The algorithm computes the outline:

1. Untitled document
2. Title

If sectioning roots are supposed to be &quot;invisible&quot; 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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>101568</commentid>
    <comment_count>1</comment_count>
    <who name="Travis Leithead [MSFT]">travil</who>
    <bug_when>2014-02-28 00:28:18 +0000</bug_when>
    <thetext>EDITOR&apos;S RESPONSE: This is an Editor&apos;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</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>