Closed
Bug 1187501
Opened 9 years ago
Closed 9 years ago
CDATA tags in innerHTML are converted to comments
Categories
(Firefox :: Untriaged, defect)
Tracking
()
People
(Reporter: mklehr, Unassigned)
Details
User Agent: Mozilla/5.0 (Windows NT 6.1; rv:39.0) Gecko/20100101 Firefox/39.0
Build ID: 20150630154324
Steps to reproduce:
In the console i tried the following:
```
var div = document.createElementNS('http://www.w3.org/1999/xhtml','xhtml:div')
div.innerHTML = '<![CDATA[foobar]]>'
div.childNodes // NodeList[Comment { data="[CDATA[foo]]", length=12, nodeType=8, more...}]
```
Actual results:
div.childNodes lists a comment with contents "[CDATA[foo]]", which is wrong.
Expected results:
It should have created a text node with contents "foobar"
Reporter | ||
Comment 1•9 years ago
|
||
(I pasted the wrong result, it should be `NodeList[Comment { data="[CDATA[foobar]]", length=12, nodeType=8, more...}]`, of course.
Comment 2•9 years ago
|
||
There's no CDATA in text/html.
Status: UNCONFIRMED → RESOLVED
Closed: 9 years ago
Resolution: --- → DUPLICATE
Comment 3•9 years ago
|
||
More information bug 435969 comment 3:
> CDATA sections aren't supported as children of HTML elements in text/html. They are parsed as bogus comments.
and bug 660660 comment 16:
> for the HTML DOM, the WHATWG is trying to avoid introducing the CDATA cruft, so the HTML5 parsing
> algorithm never emits CDATA nodes even though <![CDATA[...]]> is supported in the syntax in SVG and
> MathML contexts.
You need to log in
before you can comment on or make changes to this bug.
Description
•