Nested heading immediately after a heading of the same level incorrectly passes
andymsuk opened this issue · 6 comments
Summary
Nested heading immediately after a heading of the same level incorrectly passes the "Structure: Headings: Content must follow headings" guideline
Expected Behaviour
The following markup should cause the "Structure: Headings: Content must follow headings" guideline to fail, as there is no content between the two h2
elements:
<h1>Main heading</h1>
<h2>This is a sub-heading</h2>
<div>
<h2>Another h2 heading</h2>
<p>Hello</p>
</div>
Current Behaviour
The guideline passes
Possible Solution
Fix the logic for this guideline
If a code change for this also impacts on other issues, such as #238 do connect them.
Looking at the JS code, I'm wondering if it needs to be more specific about what elements are considered as content or not. For example, if the next sibling or next ancestor sibling is a container element, such as a <div> <span>
or <iframe>
then that in and of itself should probably not be considered content. It should probably contain some other element.
It's tricky though. Is <p> </p>
after a heading still content? What if <div></div>
is styled with dimensions and a background image, is that content?
I'd say empty div
s, span
s or iframe
s do not count as content. A div
with dimensions and a background image also doesn't count as having content, as there's nothing there for a screen reader user to find. A div
with only an img
should count has having content though, in my opinion.
I'm inclined to agree. What about something like <p> </p>
? Does that space count as content? Would that element be considered empty in a test situation?
I'd say that's also empty as again, there's no actual content in it.