Last active
August 15, 2016 23:32
-
-
Save talee/07cfa2e6123ec8e1f2548d469dedb2e7 to your computer and use it in GitHub Desktop.
Hyphen in CDATA creates more nodes instead of a single text node.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){var parser=new DOMParser();var expectedContent='hello-world';var result=parser.parseFromString('<div><![CDATA['+expectedContent+']]></div>','text/xml').firstChild.firstChild.data;if(result!=expectedContent)console.log('FAIL');else console.log('SUCCESS');console.log('result:',result);})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var parser = new DOMParser(); | |
var expectedContent = 'hello-world'; | |
var result = parser.parseFromString('<div><![CDATA[' + expectedContent + ']]></div>','text/xml').firstChild.firstChild.data; | |
if (result != expectedContent) { | |
console.log('FAIL'); | |
} else { | |
console.log('SUCCESS'); | |
} | |
console.log('result:',result); | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment