From 76e3a901530609d3c4a695ccb8a48251445c6861 Mon Sep 17 00:00:00 2001 From: David Serduke Date: Tue, 4 Dec 2007 19:37:03 +0000 Subject: [PATCH] Fixed #1763 by checking to see if .createElement() is available on the context and if isn't default to other contexts. --- src/core.js | 2 ++ test/unit/core.js | 21 +++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/core.js b/src/core.js index 5a842d5..ce487a1 100644 --- a/src/core.js +++ b/src/core.js @@ -917,6 +917,8 @@ jQuery.extend({ clean: function( elems, context ) { var ret = []; context = context || document; + if (!context.createElement) + context = context.ownerDocument || context[0] && context[0].ownerDocument || document; jQuery.each(elems, function(i, elem){ if ( !elem ) diff --git a/test/unit/core.js b/test/unit/core.js index f40f3b0..f3a3aa3 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -12,14 +12,19 @@ test("Basic requirements", function() { }); test("$()", function() { - expect(5); + expect(4); var main = $("#main"); isSet( $("div p", main).get(), q("sndp", "en", "sap"), "Basic selector with jQuery object as context" ); +/* + // disabled since this test was doing nothing. i tried to fix it but i'm not sure + // what the expected behavior should even be. FF returns "\n" for the text node // make sure this is handled - $('

\r\n

'); - ok( true, "Check for \\r and \\n in jQuery()" ); + var crlfContainer = $('

\r\n

'); + var x = crlfContainer.contents().get(0).nodeValue; + equals( x, what???, "Check for \\r and \\n in jQuery()" ); +*/ /* // Disabled until we add this functionality in var pass = true; @@ -148,7 +153,7 @@ var foo = false; test("$('html')", function() { expect(4); - + reset(); foo = false; var s = $("")[0]; @@ -163,6 +168,14 @@ test("$('html')", function() { reset(); }); +test("$('html', context)", function() { + expect(1); + + var $div = $("
"); + var $span = $("", $div); + equals($span.length, 1, "Verify a span created with a div context works"); +}); + test("length", function() { expect(1); ok( $("p").length == 6, "Get Number of Elements Found" ); -- 1.7.10.4