document.createCDATASection is not working though docs say it is

RESOLVED DUPLICATE of bug 96341

Status

()

--
minor
RESOLVED DUPLICATE of bug 96341
10 years ago
10 years ago

People

(Reporter: brettz9, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

10 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9) Gecko/2008052906 Firefox/3.0 StandardSitemap/0.1
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9) Gecko/2008052906 Firefox/3.0 StandardSitemap/0.1

document.createCDATASection() does not work and gives a not supported error. The developer docs, however, seem to indicate that it should work:
   http://developer.mozilla.org/en/docs/Browser_Feature_Detection
   http://developer.mozilla.org/en/docs/DOM_Client_Object_Cross-Reference:document

(The latter mentions it as being supported as of Gecko 1.0.1.)

Reproducible: Always

Steps to Reproduce:
1. Execute the following line in JavaScript: 
    var text = document.createCDATASection('a<a&b>cd]]>a');
Actual Results:  
The above doesn't work and instead gives the following in the Error Console: 
     Error: Operation is not supported = NS_ERROR_DOM_NOT_SUPPORTED_ERR

Expected Results:  
Should create a CDATA section for use as is in an XML document (i.e., with unescaped text (except for "]]>" which must be escaped) enclosed in a CDATA section.

Of course one can use document.createTextNode() in most cases, but this escapes the predefined entities.

var text = document.createTextNode('a<a&b>cd]]>a');

Comment 1

10 years ago
It is supported for XML documents. For HTML documents the DOM Core spec requires this exception ( http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-D26C0AF8 ):

createCDATASection
(...)
Exceptions

DOMException NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 10 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 96341
You need to log in before you can comment on or make changes to this bug.