From d43c176e80f35fe5fb1a42f3e5d2ae45e22dca92 Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Fri, 28 Feb 2025 19:04:54 +0000 Subject: [PATCH 1/5] implement headingoffset & headingreset attributes --- source | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 92 insertions(+), 2 deletions(-) diff --git a/source b/source index 61f30552fe3..35986b02358 100644 --- a/source +++ b/source @@ -13194,6 +13194,8 @@ https://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%
  • draggable
  • enterkeyhint
  • hidden
  • +
  • headingoffset
  • +
  • headingreset
  • inert
  • inputmode
  • is
  • @@ -19351,8 +19353,9 @@ interface HTMLHeadingElement : HTMLElement {

    Headings and outlines

    -

    h1h6 elements have a heading level, which is given - by the number in the element's name.

    +

    h1h6 elements have a heading level, which is + given by getting the element's computed + heading level.

    These elements represent headings. The lower a HTMLHeadingElement : HTMLElement { +

    Heading Levels & Offsets
    + +

    The headingoffset + content attribute allows authors to offset heading levels for child elements.

    + +

    The headingreset + content attribute allows authors prevent a heading offset computation from traversing beyond this + point.

    + +

    To get an element's comptued heading level, given an element element, + perform the following steps:

    + +
      +
    1. Let level be zero.

    2. + +
    3. Let max be zero.

    4. + +
    5. If element's local name is h1 then set + level to 1 and max to 8.

    6. + +
    7. If element's local name is h2 then set + level to 2 and max to 7.

    8. + +
    9. If element's local name is h3 then set + level to 3 and max to 6.

    10. + +
    11. If element's local name is h4 then set + level to 4 and max to 5.

    12. + +
    13. If element's local name is h5 then set + level to 5 and max to 4.

    14. + +
    15. If element's local name is h6 then set + level to 6 and max to 3.

    16. + +
    17. Assert: level is not zero.

    18. + +
    19. Assert: max is not zero.

    20. + +
    21. Add the result of getting an + element's computed heading offset given element and max to + level.

    22. + +
    23. Assert: level is not greather than 9.

    24. + +
    25. Return level.

    26. +
    + +

    To get an element's computed heading offset, given an element element, + and a non-negative integer max, perform the following steps. They return a + non-negative integer.

    + +
      +
    1. Let offset be element's headingoffset attribute value.

    2. + +
    3. If offset is less than zero, set offset to zero.

    4. + +
    5. If the headingreset attribute is present, then + return offset.

    6. + +
    7. Let ancestor be element.

    8. + +
    9. +

      While child is not null:

      + +
        +
      1. Let nextAncestor be the parent node of + ancestor within the flat tree.

      2. + +
      3. If nextAncestor's headingreset + attribute is present, then return offset.

      4. + +
      5. Let nextOffset be nextAncestor's headingoffset attribute value.

      6. + +
      7. If nextOffset is less than zero, set nextOffset to zero.

      8. + +
      9. Add nextOffset to offset.

      10. + +
      11. If offset is greater than or equal to max, then return + max.

      12. +
      +
    10. + +
    11. Return offset.

    12. +
    Sample outlines
    From b3665a16f30dc07384faf40e512e064645592acd Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Sat, 1 Mar 2025 09:55:47 +0000 Subject: [PATCH 2/5] s/comptued/computed --- source | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source b/source index 35986b02358..42ea33f9b0e 100644 --- a/source +++ b/source @@ -19354,7 +19354,7 @@ interface HTMLHeadingElement : HTMLElement {

    Headings and outlines

    h1h6 elements have a heading level, which is - given by getting the element's computed + given by getting the element's computed heading level.

    These elements represent HTMLHeadingElement : HTMLElement { content attribute allows authors prevent a heading offset computation from traversing beyond this point.

    -

    To get an element's comptued heading level, given an element element, +

    To get an element's computed heading level, given an element element, perform the following steps:

      From 6c54f76da917c7f2aadd8fbad3742b4d58522ef4 Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Sat, 1 Mar 2025 09:55:57 +0000 Subject: [PATCH 3/5] s/child elements/descendants/ --- source | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source b/source index 42ea33f9b0e..80cb522dbe1 100644 --- a/source +++ b/source @@ -19406,7 +19406,7 @@ interface HTMLHeadingElement : HTMLElement {
      Heading Levels & Offsets

      The headingoffset - content attribute allows authors to offset heading levels for child elements.

      + content attribute allows authors to offset heading levels for descendants.

      The headingreset content attribute allows authors prevent a heading offset computation from traversing beyond this From 24845f28a7dc131a702688d76cf4a5d32204c8b3 Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Sat, 1 Mar 2025 09:56:26 +0000 Subject: [PATCH 4/5] s/authors prevent/authors to prevent/ --- source | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source b/source index 80cb522dbe1..96a88d8d89e 100644 --- a/source +++ b/source @@ -19409,8 +19409,8 @@ interface HTMLHeadingElement : HTMLElement { content attribute allows authors to offset heading levels for descendants.

      The headingreset - content attribute allows authors prevent a heading offset computation from traversing beyond this - point.

      + content attribute allows authors to prevent a heading offset computation from traversing beyond + this point.

      To get an element's computed heading level, given an element element, perform the following steps:

      From a6b342078abaec7e693567861abf0d5aa4078d87 Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Sat, 1 Mar 2025 10:04:29 +0000 Subject: [PATCH 5/5] add note on aria-level, example --- source | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/source b/source index 96a88d8d89e..33607ed266b 100644 --- a/source +++ b/source @@ -4308,6 +4308,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
    1. aria-describedby
    2. aria-disabled
    3. aria-label
    4. +
    5. aria-level
    6. Finally, the following terms are defined ARIA: ARIA

      @@ -19491,6 +19492,34 @@ interface HTMLHeadingElement : HTMLElement {
    7. Return offset.

    +

    The use of the aria-level attribute will + take precedence over the headings computed level.

    + +
    + +

    This example shows a combination of headingoffset, + headingreset and aria-level attributes with comments demonstrating the respective + heading levels.

    + +
    <body>
    +  <main>
    +   <h1>This is a heading level 1</h1>
    +   <article headingoffset="1">
    +    <h1>This is a heading level 2</h1>
    +    <section headingoffset="1">
    +     <h1>This is a heading level 3</h1>
    +     <dialog headingreset>
    +      <h1>This is a heading level 1</h1>
    +     </dialog>
    +    </section>
    +   </article>
    +   <h1 aria-level="2">This is a heading level 2</h1>
    +  </main>
    +</body>
    + +
    +
    Sample outlines