NOTE: The current preferred location for bug reports is the GitHub issue tracker.
Bug 689 - Improve message "end tag for foo seen but there were unclosed elements"
Improve message "end tag for foo seen but there were unclosed elements"
Status: RESOLVED FIXED
Product: Validator.nu
Classification: Unclassified
Component: HTML parser
HEAD
All All
: P2 normal
Assigned To: Michael[tm] Smith
Depends on:
Blocks: 656
  Show dependency treegraph
 
Reported: 2009-12-08 12:37 CET by Simon Pieters
Modified: 2011-01-05 17:47 CET (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Pieters 2009-12-08 12:37:49 CET
http://lists.whatwg.org/pipermail/help-whatwg.org/2009-December/000377.html

It should say which elements were unclosed, possibly pointing out the position of the relevant start tags as subsequent info messages.
Comment 1 Michael[tm] Smith 2010-12-23 15:37:43 CET
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.
Comment 3 Michael[tm] Smith 2010-12-27 14:35:32 CET
updated my patch:
https://bitbucket.org/validator/htmlparser-patches/qseries?apply=t&qs_apply=unclosed-elements
https://bitbucket.org/validator/htmlparser-patches/src/tip/unclosed-elements

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
Comment 4 Simon Pieters 2010-12-27 14:44:14 CET
Fails for

<div><ul><li></div>
Comment 5 Michael[tm] Smith 2010-12-27 15:37:26 CET
(In reply to comment #4)
> Fails for
> 
> <div><ul><li></div>

Fixed now and pushed to http://www.w3.org/html/check