Bug 34947 - Error Console finding more errors than it should: Unmatched </p> encountered
Summary: Error Console finding more errors than it should: Unmatched </p> encountered
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac (Intel) OS X 10.6
: P2 Minor
Assignee: Nobody
URL: http://internal
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-15 10:14 PST by Nathan Reilly
Modified: 2010-02-15 10:33 PST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nathan Reilly 2010-02-15 10:14:03 PST
The Web inspector has seems to forget about a <p> tag 5 lines higher, and claims the </p> is unmatched. I've created a new HTML document with just the below section which triggers the error

<html>
<body>
            <p>
	                <form action="/hubbub/post/addPost/nathan" method="post" >
	                    <textarea name="content" rows="3" cols="50" id="postContent" ></textarea><br />
	                    <input type="submit" name="post" value="Post" id="post" />
	                </form>
</p>
</body>
</html>



This is the original error:
24            <p>
 25	                <form action="/hubbub/post/addPost/nathan" method="post" >
 26	                    <textarea name="content" rows="3" cols="50" id="postContent" ></textarea><br />
 27	                    <input type="submit" name="post" value="Post" id="post" />
 28	                </form>
 29	            </p>
Unmatched </p> encountered.  Converting </p> into <p></p>.
 30
Comment 1 Nathan Reilly 2010-02-15 10:14:31 PST
Running 6531.21.10, r54757
Comment 2 Mark Rowe (bdash) 2010-02-15 10:32:56 PST
This is correct behavior.  A p element cannot contain a form element, so when the opening tag for the form is encountered it is considered to implicitly close the p element.  When the </p> is later encountered it does not match any open element so a warning is emitted and it is converted in to an empty p element.

You can see a visual representation of this at <http://james.html5.org/cgi-bin/parsetree/parsetree.py?source=%3Cp%3E%3Cform%3E%3C%2Fp%3E>.  The HTML 5 specification at <http://www.whatwg.org/specs/web-apps/current-work/multipage/syntax.html#optional-tags> says the following:

A p element's end tag may be omitted if the p element is immediately followed by an address, article, aside, blockquote, dir, div, dl, fieldset, footer, form, h1, h2, h3, h4, h5, h6, header, hgroup, hr, menu, nav, ol, p, pre, section, table, or ul, element, or if there is no more content in the parent element and the parent element is not an a element.