[whatwg] Scoping elements and nested paragraphs

Consider the following markup:
    <p><object><p>X</p></p>

The html5 parsing algorithm produces the following tree:
    
<html><head></head><body><p><object><p>X</p><p></p></object></p></body></html>

whereas Firefox and Opera both produce:
    <html><head></head><body><p><object><p>X</p></object></p></body></html>

and IE produces:
    <html><head></head><body><p><object></object></p></body></html>

The main problem with the html5 output, in my opinion, is the extra 
<p></p> inside the <object>. This happens because <object> is a scoping 
element and the final </p> is not able to find the first <p>.

I've fixed this in our implementation by implementing the first 
paragraph in 'An end tag whose name is "p"' in "in body" as if it said:

---
If the stack of open elements does not have an element in scope  with 
the same tag name as that of the token, then this is a parse error

If the stack of open elements does not contain an element with the same 
tag name as that of the token, then act as if a start tag with the tag 
name p had been seen, then reprocess the current token.
---


Best regards,
Tommy

Received on Wednesday, 12 November 2008 01:49:03 UTC