Bugzilla – Bug 689
Improve message "end tag for foo seen but there were unclosed elements"
Last modified: 2011-01-05 17:47:42 CET
It should say which elements were unclosed, possibly pointing out the position of the relevant start tags as subsequent info messages.
I took a shot at doing an initial implementation of this. You can give it a try at http://www.w3.org/html/check
It just reports the nearest/bottommost unclosed element; if any other ancestors of that element are also unclosed, they don't get reported. (Though the next one up in the stack will of course get reported if the user adds an end tag for that current bottommost unclosed element and then revalidates.)
This reports that unclosed element using an error-level message (an additional error, along with any existing "end tag for foo seen but there were unclosed elements" error it's already reporting).
The htmlparser code currently does not provide any means for reporting info-level messages (it's using a stock SAX ErrorHandler, which only provides fatalError, error, and warning levels).
Arguably, the existence of each unclosed element is in fact a separate error from the fact that an end tag for another element has been seen while there were unclosed elements. But if that doesn't sound reasonable, and if we go with this implementation, we could change it to a warning. But changing it to an info message would require considerably more changes, and maybe this case on its own would not really justify making those changes.
updated my patch:
It now reports all open elements (not just the nearest/bottommost). Or it attempts to at least, and works for all the test cases I've tried so far. But it needs to be tested quite a bit more still; I've pushed the updated patch out to http://www.w3.org/html/check
(In reply to comment #4)
> Fails for
Fixed now and pushed to http://www.w3.org/html/check
Landed with my follow-up. Thanks.