From 33662cd713c28b2db0adccec170ffe93b35f098a Mon Sep 17 00:00:00 2001 From: John Resig Date: Sun, 7 Jan 2007 22:29:15 +0000 Subject: [PATCH] Fixed problem with $("div",$("body")) breaking (returning an array, of length one, containing undefined). --- src/jquery/jquery.js | 2 +- src/selector/selector.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index e566cb671..04b9ca5c1 100644 --- a/src/jquery/jquery.js +++ b/src/jquery/jquery.js @@ -1579,7 +1579,7 @@ jQuery.extend({ } } - var r = [ result[0] ]; + var r = result.length ? [ result[0] ] : []; check: for ( var i = 1, rl = result.length; i < rl; i++ ) { for ( var j = 0; j < i; j++ ) diff --git a/src/selector/selector.js b/src/selector/selector.js index 4633c3094..7f71e2e34 100644 --- a/src/selector/selector.js +++ b/src/selector/selector.js @@ -101,7 +101,7 @@ jQuery.extend({ return [ t ]; // Make sure that the context is a DOM Element - if ( context && context.nodeType == undefined ) + if ( context && !context.nodeType ) context = null; // Set the correct context (if none is provided) @@ -423,4 +423,4 @@ jQuery.extend({ return r; } -}); \ No newline at end of file +}); -- 2.39.5