Permalink
Browse files

Fixing bug: DOCTYPE was being stripped by parseFromString

This commit resolves a bug which caused the DOCTYPE to be stripped by
DOMParser().parseFromString when parsing HTML documents. The following
test case was used (run in Node.js):

var xmldom = require('xmldom'),
    DOMParser = xmldom.DOMParser,
    XMLSerializer = new xmldom.XMLSerializer(),
    string = '<!doctype
html><html><head></head><body>content</body></html>',
    doc = new DOMParser().parseFromString(string, 'text/html'),
    s = XMLSerializer,
    str = s.serializeToString(doc);
console.log(str);
  • Loading branch information...
1 parent 8417be2 commit afea22460fa7d846564285435e8f22d9181af97f @kethinov committed Jan 24, 2013
Showing with 2 additions and 2 deletions.
  1. +2 −2 sax.js
View
4 sax.js
@@ -431,7 +431,7 @@ function parseDCC(source,start,domBuilder){//sure start with '<!'
//error
return -1;
}
- case '[':
+ default:
if(source.substr(start+3,6) == 'CDATA['){
var end = source.indexOf(']]>',start+9);
domBuilder.startCDATA();
@@ -548,4 +548,4 @@ if(typeof require == 'function'){
if(typeof require == 'function'){
exports.XMLReader=XMLReader;
-}
+}

0 comments on commit afea224

Please sign in to comment.