aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorRichard Gibson <richard.gibson@gmail.com>2012-12-11 16:12:23 -0500
committerRichard Gibson <richard.gibson@gmail.com>2012-12-11 16:12:23 -0500
commitf42e1e654f43e9207c5b2f651c410f344982c2b5 (patch)
tree33d8de35f3f18ba565d38ca7e243a9254ab126d0 /test/unit
parentef6d8779de9d5959eafc0b9706b90a585aaf7a26 (diff)
downloadjquery-f42e1e654f43e9207c5b2f651c410f344982c2b5.tar.gz
jquery-f42e1e654f43e9207c5b2f651c410f344982c2b5.zip
Fix IE failures from 55313d32
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/core.js33
1 files changed, 16 insertions, 17 deletions
diff --git a/test/unit/core.js b/test/unit/core.js
index ee0fd0bb2..e505ca9b0 100644
--- a/test/unit/core.js
+++ b/test/unit/core.js
@@ -1206,32 +1206,31 @@ test("jQuery.proxy", function(){
});
test("jQuery.parseHTML", function() {
- expect( 11 );
+ expect( 12 );
+
+ var html, nodes;
equal( jQuery.parseHTML(), null, "Nothing in, null out." );
- equal( jQuery.parseHTML( null ), null, "Nothing in, null out." );
- equal( jQuery.parseHTML( "" ), null, "Nothing in, null out." );
+ equal( jQuery.parseHTML( null ), null, "Null in, null out." );
+ equal( jQuery.parseHTML( "" ), null, "Empty string in, null out." );
raises(function() {
- jQuery.parseHTML( "<div>", document.getElementById("form") );
+ jQuery.parseHTML( "<div></div>", document.getElementById("form") );
}, "Passing an element as the context raises an exception (context should be a document)");
- var elems = jQuery.parseHTML( jQuery("body").html() );
- ok( elems.length > 10, "Parse a large html string" );
- equal( jQuery.type( elems ), "array", "parseHTML returns an array rather than a nodelist" );
+ nodes = jQuery.parseHTML( jQuery("body")[0].innerHTML );
+ ok( nodes.length > 4, "Parse a large html string" );
+ equal( jQuery.type( nodes ), "array", "parseHTML returns an array rather than a nodelist" );
- var script = "<script>undefined()</script>";
- equal( jQuery.parseHTML( script ).length, 0, "Passing a script is not allowed by default" );
- raises(function() {
- jQuery(jQuery.parseHTML( script, true )).appendTo("#qunit-fixture");
- }, "Passing a script is allowed if allowScripts is true");
+ html = "<script>undefined()</script>";
+ equal( jQuery.parseHTML( html ).length, 0, "Ignore scripts by default" );
+ equal( jQuery.parseHTML( html, true )[0].nodeName.toLowerCase(), "script", "Preserve scripts when requested" );
- var html = script + "<div></div>";
- equal( jQuery.parseHTML( html )[0].nodeName.toLowerCase(), "div", "Ignore scripts by default" );
- raises(function() {
- jQuery(jQuery.parseHTML( html, true )).appendTo("#qunit-fixture");
- }, "Passing a script is allowed if allowScripts is true");
+ html += "<div></div>";
+ equal( jQuery.parseHTML( html )[0].nodeName.toLowerCase(), "div", "Preserve non-script nodes" );
+ equal( jQuery.parseHTML( html, true )[0].nodeName.toLowerCase(), "script", "Preserve script position");
equal( jQuery.parseHTML("text")[0].nodeType, 3, "Parsing text returns a text node" );
+ equal( jQuery.parseHTML( "\t<div></div>" )[0].nodeValue, "\t", "Preserve leading whitespace" );
});
test("jQuery.parseJSON", function(){