diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index e566cb67..04b9ca5c 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 4633c309..7f71e2e3 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 +});