summaryrefslogtreecommitdiffstats
path: root/js/vendor/jquery/src/selector-native.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/vendor/jquery/src/selector-native.js')
-rw-r--r--js/vendor/jquery/src/selector-native.js175
1 files changed, 107 insertions, 68 deletions
diff --git a/js/vendor/jquery/src/selector-native.js b/js/vendor/jquery/src/selector-native.js
index d8163c2f9..ee8148342 100644
--- a/js/vendor/jquery/src/selector-native.js
+++ b/js/vendor/jquery/src/selector-native.js
@@ -1,6 +1,10 @@
-define([
- "./core"
-], function( jQuery ) {
+define( [
+ "./core",
+ "./var/document",
+ "./var/documentElement",
+ "./var/hasOwn",
+ "./var/indexOf"
+], function( jQuery, document, documentElement, hasOwn, indexOf ) {
/*
* Optional (non-Sizzle) selector module for custom builds.
@@ -27,46 +31,86 @@ define([
* customize this stub for the project's specific needs.
*/
-var docElem = window.document.documentElement,
- selector_hasDuplicate,
- matches = docElem.matches ||
- docElem.webkitMatchesSelector ||
- docElem.mozMatchesSelector ||
- docElem.oMatchesSelector ||
- docElem.msMatchesSelector,
- selector_sortOrder = function( a, b ) {
- // Flag for duplicate removal
- if ( a === b ) {
- selector_hasDuplicate = true;
- return 0;
+var hasDuplicate, sortInput,
+ sortStable = jQuery.expando.split( "" ).sort( sortOrder ).join( "" ) === jQuery.expando,
+ matches = documentElement.matches ||
+ documentElement.webkitMatchesSelector ||
+ documentElement.mozMatchesSelector ||
+ documentElement.oMatchesSelector ||
+ documentElement.msMatchesSelector;
+
+function sortOrder( a, b ) {
+
+ // Flag for duplicate removal
+ if ( a === b ) {
+ hasDuplicate = true;
+ return 0;
+ }
+
+ // Sort on method existence if only one input has compareDocumentPosition
+ var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
+ if ( compare ) {
+ return compare;
+ }
+
+ // Calculate position if both inputs belong to the same document
+ compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
+ a.compareDocumentPosition( b ) :
+
+ // Otherwise we know they are disconnected
+ 1;
+
+ // Disconnected nodes
+ if ( compare & 1 ) {
+
+ // Choose the first element that is related to our preferred document
+ if ( a === document || a.ownerDocument === document &&
+ jQuery.contains( document, a ) ) {
+ return -1;
+ }
+ if ( b === document || b.ownerDocument === document &&
+ jQuery.contains( document, b ) ) {
+ return 1;
}
- var compare = b.compareDocumentPosition && a.compareDocumentPosition && a.compareDocumentPosition( b );
+ // Maintain original order
+ return sortInput ?
+ ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
+ 0;
+ }
- if ( compare ) {
- // Disconnected nodes
- if ( compare & 1 ) {
+ return compare & 4 ? -1 : 1;
+}
- // Choose the first element that is related to our document
- if ( a === document || jQuery.contains(document, a) ) {
- return -1;
- }
- if ( b === document || jQuery.contains(document, b) ) {
- return 1;
- }
+function uniqueSort( results ) {
+ var elem,
+ duplicates = [],
+ j = 0,
+ i = 0;
- // Maintain original order
- return 0;
- }
+ hasDuplicate = false;
+ sortInput = !sortStable && results.slice( 0 );
+ results.sort( sortOrder );
- return compare & 4 ? -1 : 1;
+ if ( hasDuplicate ) {
+ while ( ( elem = results[ i++ ] ) ) {
+ if ( elem === results[ i ] ) {
+ j = duplicates.push( i );
+ }
}
+ while ( j-- ) {
+ results.splice( duplicates[ j ], 1 );
+ }
+ }
- // Not directly comparable, sort on existence of method
- return a.compareDocumentPosition ? -1 : 1;
- };
+ // Clear input after sorting to release objects
+ // See https://github.com/jquery/sizzle/pull/225
+ sortInput = null;
-jQuery.extend({
+ return results;
+}
+
+jQuery.extend( {
find: function( selector, context, results, seed ) {
var elem, nodeType,
i = 0;
@@ -80,44 +124,24 @@ 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) );
- }
-
- return results;
- },
- unique: function( results ) {
- var elem,
- duplicates = [],
- i = 0,
- j = 0;
-
- selector_hasDuplicate = false;
- results.sort( selector_sortOrder );
-
- if ( selector_hasDuplicate ) {
- while ( (elem = results[i++]) ) {
- if ( elem === results[ i ] ) {
- j = duplicates.push( i );
- }
- }
- while ( j-- ) {
- results.splice( duplicates[ j ], 1 );
- }
+ jQuery.merge( results, context.querySelectorAll( selector ) );
}
return results;
},
+ uniqueSort: uniqueSort,
+ unique: uniqueSort,
text: function( elem ) {
var node,
ret = "",
@@ -125,17 +149,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;
@@ -143,19 +171,24 @@ 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";
+
+ // documentElement is verified for cases where it doesn't yet exist
+ // (such as loading iframes in IE - #4833)
+ var documentElement = elem && ( elem.ownerDocument || elem ).documentElement;
+ return documentElement ? documentElement.nodeName !== "HTML" : false;
},
expr: {
attrHandle: {},
match: {
- bool: /^(?:checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped)$/i,
+ bool: new RegExp( "^(?:checked|selected|async|autofocus|autoplay|controls|defer" +
+ "|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped)$", "i" ),
needsContext: /^[\x20\t\r\n\f]*[>+~]/
}
}
-});
+} );
jQuery.extend( jQuery.find, {
matches: function( expr, elements ) {
@@ -165,8 +198,14 @@ jQuery.extend( jQuery.find, {
return matches.call( elem, expr );
},
attr: function( elem, name ) {
- return elem.getAttribute( name );
+ var fn = jQuery.expr.attrHandle[ name.toLowerCase() ],
+
+ // Don't get fooled by Object.prototype properties (jQuery #13807)
+ value = fn && hasOwn.call( jQuery.expr.attrHandle, name.toLowerCase() ) ?
+ fn( elem, name, jQuery.isXMLDoc( elem ) ) :
+ undefined;
+ return value !== undefined ? value : elem.getAttribute( name );
}
-});
+} );
-});
+} );