From 8d3c0506c860e887d0005fd12da53f1d11ce2883 Mon Sep 17 00:00:00 2001 From: Timmy Willison Date: Mon, 6 May 2013 15:42:00 -0400 Subject: [PATCH] Check nodeType of elements passed to selector-native's find. Fixes #13577. --- src/selector-native.js | 12 +++++++++++- src/sizzle | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/selector-native.js b/src/selector-native.js index 4429795d6..58a0cec41 100644 --- a/src/selector-native.js +++ b/src/selector-native.js @@ -62,12 +62,22 @@ var selector_hasDuplicate, jQuery.extend({ find: function( selector, context, results, seed ) { - var elem, + var elem, nodeType, i = 0; results = results || []; 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 ) { while ( (elem = seed[i++]) ) { if ( jQuery.find.matchesSelector(elem, selector) ) { diff --git a/src/sizzle b/src/sizzle index b8789b87f..853c27257 160000 --- a/src/sizzle +++ b/src/sizzle @@ -1 +1 @@ -Subproject commit b8789b87f1ecb00f0de82b2a13a3474dabdab406 +Subproject commit 853c272575c692b39d4f9ea10f3f808696d1a574 -- 2.39.5