aboutsummaryrefslogtreecommitdiffstats
path: root/src/selector-native.js
diff options
context:
space:
mode:
authorTimmy Willison <timmywillisn@gmail.com>2013-05-06 15:42:00 -0400
committerTimmy Willison <timmywillisn@gmail.com>2013-05-06 15:42:00 -0400
commit8d3c0506c860e887d0005fd12da53f1d11ce2883 (patch)
treec3302601f80c834211a83143d41af9bffdd36d12 /src/selector-native.js
parent6d04ebfafb39aa0d5659be30fc98ddabc13f2609 (diff)
downloadjquery-8d3c0506c860e887d0005fd12da53f1d11ce2883.tar.gz
jquery-8d3c0506c860e887d0005fd12da53f1d11ce2883.zip
Check nodeType of elements passed to selector-native's find. Fixes #13577.
Diffstat (limited to 'src/selector-native.js')
-rw-r--r--src/selector-native.js12
1 files changed, 11 insertions, 1 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) ) {