aboutsummaryrefslogtreecommitdiffstats
path: root/src/selector-native.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/selector-native.js')
-rw-r--r--src/selector-native.js36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/selector-native.js b/src/selector-native.js
index 2d5cb3026..121a6a603 100644
--- a/src/selector-native.js
+++ b/src/selector-native.js
@@ -1,4 +1,4 @@
-define([
+define( [
"./core",
"./var/document",
"./var/documentElement"
@@ -36,6 +36,7 @@ var hasDuplicate,
documentElement.oMatchesSelector ||
documentElement.msMatchesSelector,
sortOrder = function( a, b ) {
+
// Flag for duplicate removal
if ( a === b ) {
hasDuplicate = true;
@@ -47,14 +48,15 @@ var hasDuplicate,
a.compareDocumentPosition( b );
if ( compare ) {
+
// Disconnected nodes
if ( compare & 1 ) {
// Choose the first element that is related to our document
- if ( a === document || jQuery.contains(document, a) ) {
+ if ( a === document || jQuery.contains( document, a ) ) {
return -1;
}
- if ( b === document || jQuery.contains(document, b) ) {
+ if ( b === document || jQuery.contains( document, b ) ) {
return 1;
}
@@ -78,7 +80,7 @@ var hasDuplicate,
results.sort( sortOrder );
if ( hasDuplicate ) {
- while ( (elem = results[i++]) ) {
+ while ( ( elem = results[ i++ ] ) ) {
if ( elem === results[ i ] ) {
j = duplicates.push( i );
}
@@ -91,7 +93,7 @@ var hasDuplicate,
return results;
};
-jQuery.extend({
+jQuery.extend( {
find: function( selector, context, results, seed ) {
var elem, nodeType,
i = 0;
@@ -105,18 +107,18 @@ jQuery.extend({
}
// Early return if context is not an element or document
- if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
+ if ( ( nodeType = context.nodeType ) !== 1 && nodeType !== 9 ) {
return [];
}
if ( seed ) {
- while ( (elem = seed[i++]) ) {
- if ( jQuery.find.matchesSelector(elem, selector) ) {
+ while ( ( elem = seed[ i++ ] ) ) {
+ if ( jQuery.find.matchesSelector( elem, selector ) ) {
results.push( elem );
}
}
} else {
- jQuery.merge( results, context.querySelectorAll(selector) );
+ jQuery.merge( results, context.querySelectorAll( selector ) );
}
return results;
@@ -130,17 +132,21 @@ jQuery.extend({
nodeType = elem.nodeType;
if ( !nodeType ) {
+
// If no nodeType, this is expected to be an array
- while ( (node = elem[i++]) ) {
+ while ( ( node = elem[ i++ ] ) ) {
+
// Do not traverse comment nodes
ret += jQuery.text( node );
}
} else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
+
// Use textContent for elements
return elem.textContent;
} else if ( nodeType === 3 || nodeType === 4 ) {
return elem.nodeValue;
}
+
// Do not include comment or processing instruction nodes
return ret;
@@ -148,10 +154,10 @@ jQuery.extend({
contains: function( a, b ) {
var adown = a.nodeType === 9 ? a.documentElement : a,
bup = b && b.parentNode;
- return a === bup || !!( bup && bup.nodeType === 1 && adown.contains(bup) );
+ return a === bup || !!( bup && bup.nodeType === 1 && adown.contains( bup ) );
},
isXMLDoc: function( elem ) {
- return (elem.ownerDocument || elem).documentElement.nodeName !== "HTML";
+ return ( elem.ownerDocument || elem ).documentElement.nodeName !== "HTML";
},
expr: {
attrHandle: {},
@@ -161,7 +167,7 @@ jQuery.extend({
needsContext: /^[\x20\t\r\n\f]*[>+~]/
}
}
-});
+} );
jQuery.extend( jQuery.find, {
matches: function( expr, elements ) {
@@ -173,6 +179,6 @@ jQuery.extend( jQuery.find, {
attr: function( elem, name ) {
return elem.getAttribute( name );
}
-});
+} );
-});
+} );