From f42e1e654f43e9207c5b2f651c410f344982c2b5 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Tue, 11 Dec 2012 16:12:23 -0500 Subject: [PATCH] Fix IE failures from 55313d32 --- test/unit/core.js | 33 ++++++++++++++++----------------- 1 file 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( "
", document.getElementById("form") ); + jQuery.parseHTML( "
", 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 = ""; - 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 = ""; + 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 + "
"; - 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 += "
"; + 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
" )[0].nodeValue, "\t", "Preserve leading whitespace" ); }); test("jQuery.parseJSON", function(){ -- 2.39.5