|
6 | 6 | * Released under the MIT license |
7 | 7 | * http://jquery.org/license |
8 | 8 | * |
9 | | - * Date: 2013-06-01 |
| 9 | + * Date: 2013-06-02 |
10 | 10 | */ |
11 | 11 | (function( window, undefined ) { |
12 | 12 |
|
@@ -39,7 +39,13 @@ var i, |
39 | 39 | tokenCache = createCache(), |
40 | 40 | compilerCache = createCache(), |
41 | 41 | 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 | + }, |
43 | 49 |
|
44 | 50 | // General-purpose constants |
45 | 51 | strundefined = typeof undefined, |
@@ -346,61 +352,15 @@ function assert( fn ) { |
346 | 352 | * @param {Function} handler The method that will be applied if the test fails |
347 | 353 | * @param {Boolean} test The result of a test. If true, null will be set as the handler in leiu of the specified handler |
348 | 354 | */ |
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; |
354 | 358 |
|
355 | 359 | 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; |
360 | 361 | } |
361 | 362 | } |
362 | 363 |
|
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 | | - |
404 | 364 | /** |
405 | 365 | * Checks document order of two siblings |
406 | 366 | * @param {Element} a |
@@ -524,28 +484,10 @@ setDocument = Sizzle.setDocument = function( node ) { |
524 | 484 | // Support: IE<8 |
525 | 485 | // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans) |
526 | 486 | 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 | | - |
537 | 487 | div.className = "i"; |
538 | 488 | return !div.getAttribute("className"); |
539 | 489 | }); |
540 | 490 |
|
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 | | - |
549 | 491 | /* getElement(s)By* |
550 | 492 | ---------------------------------------------------------------------- */ |
551 | 493 |
|
@@ -756,13 +698,6 @@ setDocument = Sizzle.setDocument = function( node ) { |
756 | 698 | /* Sorting |
757 | 699 | ---------------------------------------------------------------------- */ |
758 | 700 |
|
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 | | - |
766 | 701 | // Document order sorting |
767 | 702 | sortOrder = docElem.compareDocumentPosition ? |
768 | 703 | function( a, b ) { |
@@ -905,9 +840,9 @@ Sizzle.attr = function( elem, name ) { |
905 | 840 |
|
906 | 841 | var fn = Expr.attrHandle[ name.toLowerCase() ], |
907 | 842 | // 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() ) ? |
909 | 844 | fn( elem, name, !documentIsHTML ) : |
910 | | - undefined ); |
| 845 | + undefined; |
911 | 846 |
|
912 | 847 | return val === undefined ? |
913 | 848 | support.attributes || !documentIsHTML ? |
@@ -1984,14 +1919,65 @@ Expr.setFilters = new setFilters(); |
1984 | 1919 | // Sort stability |
1985 | 1920 | support.sortStable = expando.split("").sort( sortOrder ).join("") === expando; |
1986 | 1921 |
|
1987 | | -// Initialize against the default document |
1988 | | -setDocument(); |
1989 | | - |
1990 | 1922 | // Support: Chrome<<14 |
1991 | 1923 | // Always assume duplicates if they aren't passed to the comparison function |
1992 | | -[0, 0].sort( sortOrder ); |
1993 | 1924 | support.detectDuplicates = hasDuplicate; |
1994 | 1925 |
|
| 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 | + |
1995 | 1981 | // EXPOSE |
1996 | 1982 | if ( typeof define === "function" && define.amd ) { |
1997 | 1983 | define(function() { return Sizzle; }); |
|
0 commit comments