Skip to content

Commit 238bc32

Browse files
committed
Sizzle: update 2.1.1
1 parent 3d77c2e commit 238bc32

File tree

7 files changed

+113
-49
lines changed

7 files changed

+113
-49
lines changed

Gruntfile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ module.exports = function( grunt ) {
5151
},
5252
files: {
5353
"sizzle/dist": "sizzle/dist",
54-
"sizzle/MIT-LICENSE.txt": "sizzle/MIT-LICENSE.txt",
54+
"sizzle/LICENSE.txt": "sizzle/LICENSE.txt",
5555

5656
"qunit/qunit.js": "qunitjs/qunit/qunit.js",
5757
"qunit/qunit.css": "qunitjs/qunit/qunit.css",
58-
"qunit/MIT-LICENSE.txt": "qunitjs/MIT-LICENSE.txt",
58+
"qunit/LICENSE.txt": "qunitjs/LICENSE.txt",
5959

6060
"requirejs/require.js": "requirejs/require.js",
6161

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1-
Copyright 2013 jQuery Foundation and other contributors
2-
http://jquery.com/
1+
Copyright 2006, 2014 jQuery Foundation and other contributors,
2+
https://jquery.org/
3+
4+
This software consists of voluntary contributions made by many
5+
individuals. For exact contribution history, see the revision history
6+
available at https://github.com/jquery/qunit
7+
8+
The following license applies to all parts of this software except as
9+
documented below:
10+
11+
====
312

413
Permission is hereby granted, free of charge, to any person obtaining
514
a copy of this software and associated documentation files (the
@@ -19,3 +28,10 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
1928
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
2029
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2130
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31+
32+
====
33+
34+
All files located in the node_modules and external directories are
35+
externally maintained libraries used by this software which have their
36+
own licenses; we recommend you read them, as their terms may differ from
37+
the terms above.
Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1-
Copyright 2013 jQuery Foundation and other contributors
2-
http://jquery.com/
1+
Copyright 2008, 2014 jQuery Foundation and other contributors,
2+
https://jquery.org/
3+
4+
This software consists of voluntary contributions made by many
5+
individuals. For exact contribution history, see the revision history
6+
available at https://github.com/jquery/sizzle
7+
8+
The following license applies to all parts of this software except as
9+
documented below:
10+
11+
====
312

413
Permission is hereby granted, free of charge, to any person obtaining
514
a copy of this software and associated documentation files (the
@@ -19,3 +28,10 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
1928
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
2029
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2130
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31+
32+
====
33+
34+
All files located in the node_modules and external directories are
35+
externally maintained libraries used by this software which have their
36+
own licenses; we recommend you read them, as their terms may differ from
37+
the terms above.

external/sizzle/dist/sizzle.js

Lines changed: 71 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*!
2-
* Sizzle CSS Selector Engine v2.0.0
2+
* Sizzle CSS Selector Engine v2.1.1
33
* http://sizzlejs.com/
44
*
55
* Copyright 2008, 2014 jQuery Foundation, Inc. and other contributors
66
* Released under the MIT license
77
* http://jquery.org/license
88
*
9-
* Date: 2014-07-01
9+
* Date: 2014-12-15
1010
*/
1111
(function( window ) {
1212

@@ -33,7 +33,7 @@ var i,
3333
contains,
3434

3535
// Instance-specific data
36-
expando = "sizzle" + -(new Date()),
36+
expando = "sizzle" + 1 * new Date(),
3737
preferredDoc = window.document,
3838
dirruns = 0,
3939
done = 0,
@@ -48,7 +48,6 @@ var i,
4848
},
4949

5050
// General-purpose constants
51-
strundefined = typeof undefined,
5251
MAX_NEGATIVE = 1 << 31,
5352

5453
// Instance methods
@@ -58,12 +57,13 @@ var i,
5857
push_native = arr.push,
5958
push = arr.push,
6059
slice = arr.slice,
61-
// Use a stripped-down indexOf if we can't use a native one
62-
indexOf = arr.indexOf || function( elem ) {
60+
// Use a stripped-down indexOf as it's faster than native
61+
// http://jsperf.com/thor-indexof-vs-for/5
62+
indexOf = function( list, elem ) {
6363
var i = 0,
64-
len = this.length;
64+
len = list.length;
6565
for ( ; i < len; i++ ) {
66-
if ( this[i] === elem ) {
66+
if ( list[i] === elem ) {
6767
return i;
6868
}
6969
}
@@ -99,6 +99,7 @@ var i,
9999
")\\)|)",
100100

101101
// Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
102+
rwhitespace = new RegExp( whitespace + "+", "g" ),
102103
rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
103104

104105
rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
@@ -150,6 +151,14 @@ var i,
150151
String.fromCharCode( high + 0x10000 ) :
151152
// Supplemental Plane codepoint (surrogate pair)
152153
String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
154+
},
155+
156+
// Used for iframes
157+
// See setDocument()
158+
// Removing the function wrapper causes a "Permission Denied"
159+
// error in IE
160+
unloadHandler = function() {
161+
setDocument();
153162
};
154163

155164
// Optimize for push.apply( _, NodeList )
@@ -197,14 +206,14 @@ function Sizzle( selector, context, results, seed ) {
197206
return results;
198207
}
199208

200-
if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
209+
if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 && nodeType !== 11 ) {
201210
return [];
202211
}
203212

204213
if ( documentIsHTML && !seed ) {
205214

206-
// Shortcuts
207-
if ( (match = rquickExpr.exec( selector )) ) {
215+
// Try to shortcut find operations when possible (e.g., not under DocumentFragment)
216+
if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
208217
// Speed-up: Sizzle("#ID")
209218
if ( (m = match[1]) ) {
210219
if ( nodeType === 9 ) {
@@ -246,7 +255,7 @@ function Sizzle( selector, context, results, seed ) {
246255
if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
247256
nid = old = expando;
248257
newContext = context;
249-
newSelector = nodeType === 9 && selector;
258+
newSelector = nodeType !== 1 && selector;
250259

251260
// qSA works strangely on Element-rooted queries
252261
// We can work around this by specifying an extra ID on the root
@@ -433,7 +442,7 @@ function createPositionalPseudo( fn ) {
433442
* @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
434443
*/
435444
function testContext( context ) {
436-
return context && typeof context.getElementsByTagName !== strundefined && context;
445+
return context && typeof context.getElementsByTagName !== "undefined" && context;
437446
}
438447

439448
// Expose support vars for convenience
@@ -457,9 +466,8 @@ isXML = Sizzle.isXML = function( elem ) {
457466
* @returns {Object} Returns the current document
458467
*/
459468
setDocument = Sizzle.setDocument = function( node ) {
460-
var hasCompare,
461-
doc = node ? node.ownerDocument || node : preferredDoc,
462-
parent = doc.defaultView;
469+
var hasCompare, parent,
470+
doc = node ? node.ownerDocument || node : preferredDoc;
463471

464472
// If no document and documentElement is available, return
465473
if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
@@ -469,9 +477,7 @@ setDocument = Sizzle.setDocument = function( node ) {
469477
// Set our document
470478
document = doc;
471479
docElem = doc.documentElement;
472-
473-
// Support tests
474-
documentIsHTML = !isXML( doc );
480+
parent = doc.defaultView;
475481

476482
// Support: IE>8
477483
// If iframe document is assigned to "document" variable and if iframe has been reloaded,
@@ -480,21 +486,22 @@ setDocument = Sizzle.setDocument = function( node ) {
480486
if ( parent && parent !== parent.top ) {
481487
// IE11 does not have attachEvent, so all must suffer
482488
if ( parent.addEventListener ) {
483-
parent.addEventListener( "unload", function() {
484-
setDocument();
485-
}, false );
489+
parent.addEventListener( "unload", unloadHandler, false );
486490
} else if ( parent.attachEvent ) {
487-
parent.attachEvent( "onunload", function() {
488-
setDocument();
489-
});
491+
parent.attachEvent( "onunload", unloadHandler );
490492
}
491493
}
492494

495+
/* Support tests
496+
---------------------------------------------------------------------- */
497+
documentIsHTML = !isXML( doc );
498+
493499
/* Attributes
494500
---------------------------------------------------------------------- */
495501

496502
// Support: IE<8
497-
// Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
503+
// Verify that getAttribute really returns attributes and not properties
504+
// (excepting IE8 booleans)
498505
support.attributes = assert(function( div ) {
499506
div.className = "i";
500507
return !div.getAttribute("className");
@@ -524,7 +531,7 @@ setDocument = Sizzle.setDocument = function( node ) {
524531
// ID find and filter
525532
if ( support.getById ) {
526533
Expr.find["ID"] = function( id, context ) {
527-
if ( typeof context.getElementById !== strundefined && documentIsHTML ) {
534+
if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
528535
var m = context.getElementById( id );
529536
// Check parentNode to catch when Blackberry 4.6 returns
530537
// nodes that are no longer in the document #6963
@@ -545,7 +552,7 @@ setDocument = Sizzle.setDocument = function( node ) {
545552
Expr.filter["ID"] = function( id ) {
546553
var attrId = id.replace( runescape, funescape );
547554
return function( elem ) {
548-
var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
555+
var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
549556
return node && node.value === attrId;
550557
};
551558
};
@@ -554,14 +561,20 @@ setDocument = Sizzle.setDocument = function( node ) {
554561
// Tag
555562
Expr.find["TAG"] = support.getElementsByTagName ?
556563
function( tag, context ) {
557-
if ( typeof context.getElementsByTagName !== strundefined ) {
564+
if ( typeof context.getElementsByTagName !== "undefined" ) {
558565
return context.getElementsByTagName( tag );
566+
567+
// DocumentFragment nodes don't have gEBTN
568+
} else if ( support.qsa ) {
569+
return context.querySelectorAll( tag );
559570
}
560571
} :
572+
561573
function( tag, context ) {
562574
var elem,
563575
tmp = [],
564576
i = 0,
577+
// By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
565578
results = context.getElementsByTagName( tag );
566579

567580
// Filter out possible comments
@@ -608,7 +621,9 @@ setDocument = Sizzle.setDocument = function( node ) {
608621
// setting a boolean content attribute,
609622
// since its presence should be enough
610623
// http://bugs.jquery.com/ticket/12359
611-
div.innerHTML = "<select msallowcapture=''><option selected=''></option></select>";
624+
docElem.appendChild( div ).innerHTML = "<a id='" + expando + "'></a>" +
625+
"<select id='" + expando + "-\f]' msallowcapture=''>" +
626+
"<option selected=''></option></select>";
612627

613628
// Support: IE8, Opera 11-12.16
614629
// Nothing should be selected when empty strings follow ^= or $= or *=
@@ -624,12 +639,24 @@ setDocument = Sizzle.setDocument = function( node ) {
624639
rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
625640
}
626641

642+
// Support: Chrome<29, Android<4.2+, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.7+
643+
if ( !div.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
644+
rbuggyQSA.push("~=");
645+
}
646+
627647
// Webkit/Opera - :checked should return selected option elements
628648
// http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
629649
// IE8 throws error here and will not see later tests
630650
if ( !div.querySelectorAll(":checked").length ) {
631651
rbuggyQSA.push(":checked");
632652
}
653+
654+
// Support: Safari 8+, iOS 8+
655+
// https://bugs.webkit.org/show_bug.cgi?id=136851
656+
// In-page `selector#id sibing-combinator selector` fails
657+
if ( !div.querySelectorAll( "a#" + expando + "+*" ).length ) {
658+
rbuggyQSA.push(".#.+[+~]");
659+
}
633660
});
634661

635662
assert(function( div ) {
@@ -746,7 +773,7 @@ setDocument = Sizzle.setDocument = function( node ) {
746773

747774
// Maintain original order
748775
return sortInput ?
749-
( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
776+
( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
750777
0;
751778
}
752779

@@ -773,7 +800,7 @@ setDocument = Sizzle.setDocument = function( node ) {
773800
aup ? -1 :
774801
bup ? 1 :
775802
sortInput ?
776-
( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
803+
( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
777804
0;
778805

779806
// If the nodes are siblings, we can do a quick check
@@ -836,7 +863,7 @@ Sizzle.matchesSelector = function( elem, expr ) {
836863
elem.document && elem.document.nodeType !== 11 ) {
837864
return ret;
838865
}
839-
} catch(e) {}
866+
} catch (e) {}
840867
}
841868

842869
return Sizzle( expr, document, null, [ elem ] ).length > 0;
@@ -1055,7 +1082,7 @@ Expr = Sizzle.selectors = {
10551082
return pattern ||
10561083
(pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
10571084
classCache( className, function( elem ) {
1058-
return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" );
1085+
return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
10591086
});
10601087
},
10611088

@@ -1077,7 +1104,7 @@ Expr = Sizzle.selectors = {
10771104
operator === "^=" ? check && result.indexOf( check ) === 0 :
10781105
operator === "*=" ? check && result.indexOf( check ) > -1 :
10791106
operator === "$=" ? check && result.slice( -check.length ) === check :
1080-
operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
1107+
operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
10811108
operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
10821109
false;
10831110
};
@@ -1197,7 +1224,7 @@ Expr = Sizzle.selectors = {
11971224
matched = fn( seed, argument ),
11981225
i = matched.length;
11991226
while ( i-- ) {
1200-
idx = indexOf.call( seed, matched[i] );
1227+
idx = indexOf( seed, matched[i] );
12011228
seed[ idx ] = !( matches[ idx ] = matched[i] );
12021229
}
12031230
}) :
@@ -1236,6 +1263,8 @@ Expr = Sizzle.selectors = {
12361263
function( elem, context, xml ) {
12371264
input[0] = elem;
12381265
matcher( input, null, xml, results );
1266+
// Don't keep the element (issue #299)
1267+
input[0] = null;
12391268
return !results.pop();
12401269
};
12411270
}),
@@ -1669,7 +1698,7 @@ function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postS
16691698
i = matcherOut.length;
16701699
while ( i-- ) {
16711700
if ( (elem = matcherOut[i]) &&
1672-
(temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
1701+
(temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
16731702

16741703
seed[temp] = !(results[temp] = elem);
16751704
}
@@ -1704,13 +1733,16 @@ function matcherFromTokens( tokens ) {
17041733
return elem === checkContext;
17051734
}, implicitRelative, true ),
17061735
matchAnyContext = addCombinator( function( elem ) {
1707-
return indexOf.call( checkContext, elem ) > -1;
1736+
return indexOf( checkContext, elem ) > -1;
17081737
}, implicitRelative, true ),
17091738
matchers = [ function( elem, context, xml ) {
1710-
return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
1739+
var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
17111740
(checkContext = context).nodeType ?
17121741
matchContext( elem, context, xml ) :
17131742
matchAnyContext( elem, context, xml ) );
1743+
// Avoid hanging onto element (issue #299)
1744+
checkContext = null;
1745+
return ret;
17141746
} ];
17151747

17161748
for ( ; i < len; i++ ) {

0 commit comments

Comments
 (0)