Bug 43953
| Summary: | innerHTML Delete HEAD and BODY tags | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Rob Ellis <rob> |
| Component: | DOM | Assignee: | Adam Barth <abarth> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | abarth, ap |
| Priority: | P2 | ||
| Version: | 528+ (Nightly build) | ||
| Hardware: | PC | ||
| OS: | OS X 10.5 | ||
Rob Ellis
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 | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Alexey Proskuryakov
What behavior do you expect the first code snippet to have? Do you expect the resulting document to have two heads?
Rob Ellis
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
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
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
Our behavior should match the HTML5 spec now.