Check nodeType of elements passed to selector-native's find. Fixes #13577.

This commit is contained in:
Timmy Willison 2013-05-06 15:42:00 -04:00
parent 6d04ebfafb
commit 8d3c0506c8
2 changed files with 12 additions and 2 deletions

View File

@ -62,12 +62,22 @@ var selector_hasDuplicate,
jQuery.extend({ jQuery.extend({
find: function( selector, context, results, seed ) { find: function( selector, context, results, seed ) {
var elem, var elem, nodeType,
i = 0; i = 0;
results = results || []; results = results || [];
context = context || document; context = context || document;
// Same basic safeguard as Sizzle
if ( !selector || typeof selector !== "string" ) {
return results;
}
// Early return if context is not an element or document
if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
return [];
}
if ( seed ) { if ( seed ) {
while ( (elem = seed[i++]) ) { while ( (elem = seed[i++]) ) {
if ( jQuery.find.matchesSelector(elem, selector) ) { if ( jQuery.find.matchesSelector(elem, selector) ) {

@ -1 +1 @@
Subproject commit b8789b87f1ecb00f0de82b2a13a3474dabdab406 Subproject commit 853c272575c692b39d4f9ea10f3f808696d1a574