RESOLVED FIXED 43953
innerHTML Delete HEAD and BODY tags
https://bugs.webkit.org/show_bug.cgi?id=43953
Summary innerHTML Delete HEAD and BODY tags
Rob Ellis
Reported 2010-08-13 00:28:19 PDT
Given main = document.getElementsByTagName("BODY")[0]; var div = document.createElement('DIV'); div.innerHTML = "<head>This is Second Head Node</HEAD>"; main.appendChild(div); The HEAD tag is not created. Same for Body. This approach does work. main = document.getElementsByTagName("BODY")[0]; var div = document.createElement('DIV'); var body = document.createElement('BODY'); div.appendChild(body); main.appendChild(div); This issue appears to be identical to this FF issue. https://bugzilla.mozilla.org/show_bug.cgi?id=189051 Cheers Rob
Attachments
Alexey Proskuryakov
Comment 1 2010-08-13 07:09:28 PDT
What behavior do you expect the first code snippet to have? Do you expect the resulting document to have two heads?
Rob Ellis
Comment 2 2010-08-13 08:43:47 PDT
Add semantics aside I expect <body> <div> <head>This is the Second Head Node</head> </div> </body> I get this <body> <div> This is the Second Head Node </div> </body> innerHTML will except any other arbitrary tag except head and body (semantic or not)
Adam Barth
Comment 3 2010-08-13 10:07:26 PDT
Yes. You're running into some wrong code that will be removed shortly when we turn on the HTML5 parsing algorithm for fragment parsing. Thanks for the report.
Adam Barth
Comment 4 2010-08-13 10:08:45 PDT
Here you can see a diff where we've disabled that code on the HTML5 tree builder codepath: http://trac.webkit.org/changeset/65212/trunk/WebCore/dom/Element.cpp
Adam Barth
Comment 5 2011-10-13 15:38:05 PDT
Our behavior should match the HTML5 spec now.
Note You need to log in before you can comment on or make changes to this bug.