I have been doing some reading on the DOM documents and it seems that in the new standard the node type for CDATA sections is now gone.
Seems that mozilla got rid of CDATA_SECTION_NODE since it is now deprecated. In the DOM document
now it says that its historical. My question is: If now the function nodeType does not detect the CDATA_SECTION_NODE how does the DOM deal with those tags? That is if I were to write
<script><![CDATA[ /*Some code with < & and what not */ ]]></script>
then how will the browsers deal with this if there is no node to handle the CDATA sections? Does it simply read the contents and ignores the <!CDATA[ and ]]> strings?
Furthermore, is there anywhere that explains the decision to get rid of it?
There are a few distinct components to CDATA handling:
CDATASection interface with a Node.CDATA_SECTION_NODE nodeType) or whether it's just a Text node.<!CDATA[ ... ]]> -- how does it treat the special characters (<>&) inside CDATA, does it emit a single node for the CDATA section, and if so does it create a Text node or a CDATASection node in the DOM.<![CDATA[ ]]> or with special characters escaped)As far as I can tell for #2 the HTML5 parser spec is implemented in most browsers and according to it, the parser never emits CDATASection nodes and depending on the context
<script> or <math>>.The question of how and if CDATA should be exposed in the DOM is not agreed upon and despite being removed from the DOM4 spec, it is still available in at least Gecko (see Mozilla bug 660660, W3C bugs 12841 and 27386).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With