Closed Bug 440311 Opened 16 years ago Closed 16 years ago

document.createCDATASection is not working though docs say it is

Categories

(Firefox :: General, defect)

x86
Windows Vista
defect
Not set
minor

Tracking

()

RESOLVED DUPLICATE of bug 96341

People

(Reporter: brettz9, Unassigned)

Details

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');
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
Closed: 16 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.