This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 18824 - html parsing algorithm possible bug wrt <p> & <div>
Summary: html parsing algorithm possible bug wrt <p> & <div>
Status: RESOLVED INVALID
Alias: None
Product: WHATWG
Classification: Unclassified
Component: HTML (show other bugs)
Version: unspecified
Hardware: PC Windows NT
: P2 normal
Target Milestone: Unsorted
Assignee: Ian 'Hixie' Hickson
QA Contact: contributor
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-10 08:25 UTC by apavan.iitk
Modified: 2012-09-10 09:36 UTC (History)
2 users (show)

See Also:


Attachments

Description apavan.iitk 2012-09-10 08:25:12 UTC
<html>
 <head></head>
 <body>
  <p>
   <table>
    <form>
     <div>
     this is a test div
     </div>
    </form>
   </table>
  </p>
 </body>
</html>

when the above test case is parsed according to the spec
it becomes:

<html>
 <head></head>
 <body>
 <p>
  <div>
    this is a test div
  </div>

  <table>
  <form></form>
  </table>
 </p>

</body>
</html>

[in this <div> is inside <p>, while the spec explicitly states that <div>
elements will be moved out of <p>]

Thus the output of the parsing algorithm violates the spec!!
Comment 1 Simon Pieters 2012-09-10 08:47:55 UTC
I believe this is intentional. The foster parenting algorithm doesn't care whether the new parent is an appropriate one.

Where does the spec say that div will be moved out of p?
Comment 2 apavan.iitk 2012-09-10 09:25:01 UTC
(In reply to comment #1)
> I believe this is intentional. The foster parenting algorithm doesn't care
> whether the new parent is an appropriate one.
> 
> Where does the spec say that div will be moved out of p?

well if you have
<p>
text inside p
<div>
  text inside div
</div>
</p>

it is converted to:

<p>
text inside p
</p>
<div>
  text inside div
</div>
<p></p>

this is not really moving <div> outside <p> but at least means what <div> cannot be placed inside <p> as per the standard

Please check answer 3 at
http://stackoverflow.com/questions/10763780/putting-div-inside-p-is-adding-an-extra-p
Comment 3 Simon Pieters 2012-09-10 09:36:38 UTC
I was asking for a statement in the spec which the spec contradicts. Different handling for different cases is intentional. AFAICT there's no spec bug here.