Skip to content

Commit 07a5f1f

Browse files
committed
No ticket: Save 40 bytes
1 parent decefb6 commit 07a5f1f

File tree

4 files changed

+139
-167
lines changed

4 files changed

+139
-167
lines changed

dist/sizzle.js

Lines changed: 69 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Released under the MIT license
77
* http://jquery.org/license
88
*
9-
* Date: 2013-06-01
9+
* Date: 2013-06-02
1010
*/
1111
(function( window, undefined ) {
1212

@@ -39,7 +39,13 @@ var i,
3939
tokenCache = createCache(),
4040
compilerCache = createCache(),
4141
hasDuplicate = false,
42-
sortOrder = function() { return 0; },
42+
sortOrder = function( a, b ) {
43+
if ( a === b ) {
44+
hasDuplicate = true;
45+
return 0;
46+
}
47+
return 0;
48+
},
4349

4450
// General-purpose constants
4551
strundefined = typeof undefined,
@@ -346,61 +352,15 @@ function assert( fn ) {
346352
* @param {Function} handler The method that will be applied if the test fails
347353
* @param {Boolean} test The result of a test. If true, null will be set as the handler in leiu of the specified handler
348354
*/
349-
function addHandle( attrs, handler, test ) {
350-
attrs = attrs.split("|");
351-
var current,
352-
i = attrs.length,
353-
setHandle = test ? null : handler;
355+
function addHandle( attrs, handler ) {
356+
var arr = attrs.split("|"),
357+
i = attrs.length;
354358

355359
while ( i-- ) {
356-
// Don't override a user's handler
357-
if ( !(current = Expr.attrHandle[ attrs[i] ]) || current === handler ) {
358-
Expr.attrHandle[ attrs[i] ] = setHandle;
359-
}
360+
Expr.attrHandle[ arr[i] ] = handler;
360361
}
361362
}
362363

363-
/**
364-
* Fetches boolean attributes by node
365-
* @param {Element} elem
366-
* @param {String} name
367-
*/
368-
function boolHandler( elem, name, isXML ) {
369-
var val;
370-
return isXML ?
371-
undefined :
372-
(val = elem.getAttributeNode( name )) && val.specified ?
373-
val.value :
374-
elem[ name ] === true ? name.toLowerCase() : null;
375-
}
376-
377-
/**
378-
* Fetches attributes without interpolation
379-
* http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
380-
* @param {Element} elem
381-
* @param {String} name
382-
*/
383-
function interpolationHandler( elem, name, isXML ) {
384-
var val;
385-
return isXML ?
386-
undefined :
387-
(val = elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 ));
388-
}
389-
390-
/**
391-
* Uses defaultValue to retrieve value in IE6/7
392-
* @param {Element} elem
393-
* @param {String} name
394-
*/
395-
function valueHandler( elem, name, isXML ) {
396-
var val;
397-
return isXML ?
398-
undefined :
399-
elem.nodeName.toLowerCase() !== "input" ?
400-
undefined :
401-
(val = elem.defaultValue);
402-
}
403-
404364
/**
405365
* Checks document order of two siblings
406366
* @param {Element} a
@@ -524,28 +484,10 @@ setDocument = Sizzle.setDocument = function( node ) {
524484
// Support: IE<8
525485
// Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
526486
support.attributes = assert(function( div ) {
527-
528-
// Support: IE<8
529-
// Prevent attribute/property "interpolation"
530-
div.innerHTML = "<a href='#'></a>";
531-
addHandle( "type|href|height|width", interpolationHandler, div.firstChild.getAttribute("href") === "#" );
532-
533-
// Support: IE<9
534-
// Use getAttributeNode to fetch booleans when getAttribute lies
535-
addHandle( booleans, boolHandler, div.getAttribute("disabled") == null );
536-
537487
div.className = "i";
538488
return !div.getAttribute("className");
539489
});
540490

541-
// Support: IE<9
542-
// Verify that getAttribute is accurate for "value" specifically
543-
addHandle( "value", valueHandler, support.attributes && assert(function( div ) {
544-
div.innerHTML = "<input/>";
545-
div.firstChild.setAttribute( "value", "" );
546-
return div.firstChild.getAttribute( "value" ) === "";
547-
}) );
548-
549491
/* getElement(s)By*
550492
---------------------------------------------------------------------- */
551493

@@ -756,13 +698,6 @@ setDocument = Sizzle.setDocument = function( node ) {
756698
/* Sorting
757699
---------------------------------------------------------------------- */
758700

759-
// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
760-
// Detached nodes confoundingly follow *each other*
761-
support.sortDetached = assert(function( div1 ) {
762-
// Should return 1, but returns 4 (following)
763-
return div1.compareDocumentPosition( doc.createElement("div") ) & 1;
764-
});
765-
766701
// Document order sorting
767702
sortOrder = docElem.compareDocumentPosition ?
768703
function( a, b ) {
@@ -905,9 +840,9 @@ Sizzle.attr = function( elem, name ) {
905840

906841
var fn = Expr.attrHandle[ name.toLowerCase() ],
907842
// Don't get fooled by Object.prototype properties (jQuery #13807)
908-
val = ( fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
843+
val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
909844
fn( elem, name, !documentIsHTML ) :
910-
undefined );
845+
undefined;
911846

912847
return val === undefined ?
913848
support.attributes || !documentIsHTML ?
@@ -1984,14 +1919,65 @@ Expr.setFilters = new setFilters();
19841919
// Sort stability
19851920
support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
19861921

1987-
// Initialize against the default document
1988-
setDocument();
1989-
19901922
// Support: Chrome<<14
19911923
// Always assume duplicates if they aren't passed to the comparison function
1992-
[0, 0].sort( sortOrder );
19931924
support.detectDuplicates = hasDuplicate;
19941925

1926+
// Initialize against the default document
1927+
setDocument();
1928+
1929+
// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
1930+
// Detached nodes confoundingly follow *each other*
1931+
support.sortDetached = assert(function( div1 ) {
1932+
// Should return 1, but returns 4 (following)
1933+
return div1.compareDocumentPosition( document.createElement("div") ) & 1;
1934+
});
1935+
1936+
// Support: IE<8
1937+
// Prevent attribute/property "interpolation"
1938+
// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
1939+
if ( !assert(function( div ) {
1940+
div.innerHTML = "<a href='#'></a>";
1941+
return div.firstChild.getAttribute("href") === "#" ;
1942+
}) ) {
1943+
addHandle( "type|href|height|width", function( elem, name, isXML ) {
1944+
return isXML ?
1945+
undefined :
1946+
elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
1947+
});
1948+
}
1949+
1950+
// Support: IE<9
1951+
// Use defaultValue in place of getAttribute("value")
1952+
if ( !support.attributes || !assert(function( div ) {
1953+
div.innerHTML = "<input/>";
1954+
div.firstChild.setAttribute( "value", "" );
1955+
return div.firstChild.getAttribute( "value" ) === "";
1956+
}) ) {
1957+
addHandle( "value", function( elem, name, isXML ) {
1958+
return isXML ?
1959+
undefined :
1960+
elem.nodeName.toLowerCase() !== "input" ?
1961+
undefined :
1962+
elem.defaultValue;
1963+
});
1964+
}
1965+
1966+
// Support: IE<9
1967+
// Use getAttributeNode to fetch booleans when getAttribute lies
1968+
if ( !assert(function( div ) {
1969+
return div.getAttribute("disabled") == null;
1970+
}) ) {
1971+
addHandle( booleans, function( elem, name, isXML ) {
1972+
var val;
1973+
return isXML ?
1974+
undefined :
1975+
(val = elem.getAttributeNode( name )) && val.specified ?
1976+
val.value :
1977+
elem[ name ] === true ? name.toLowerCase() : null;
1978+
});
1979+
}
1980+
19951981
// EXPOSE
19961982
if ( typeof define === "function" && define.amd ) {
19971983
define(function() { return Sizzle; });

0 commit comments

Comments
 (0)