Skip to content

Commit decefb6

Browse files
committed
Fix jQuery #13974: Screen XML documents from special attrHandle processing
1 parent a431c02 commit decefb6

File tree

5 files changed

+75
-62
lines changed

5 files changed

+75
-62
lines changed

dist/sizzle.js

Lines changed: 24 additions & 25 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-05-27
9+
* Date: 2013-06-01
1010
*/
1111
(function( window, undefined ) {
1212

@@ -365,12 +365,13 @@ function addHandle( attrs, handler, test ) {
365365
* @param {Element} elem
366366
* @param {String} name
367367
*/
368-
function boolHandler( elem, name ) {
369-
// XML does not need to be checked as this will not be assigned for XML documents
370-
var val = elem.getAttributeNode( name );
371-
return val && val.specified ?
372-
val.value :
373-
elem[ name ] === true ? name.toLowerCase() : null;
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;
374375
}
375376

376377
/**
@@ -379,23 +380,25 @@ function boolHandler( elem, name ) {
379380
* @param {Element} elem
380381
* @param {String} name
381382
*/
382-
function interpolationHandler( elem, name ) {
383-
// XML does not need to be checked as this will not be assigned for XML documents
384-
return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
383+
function interpolationHandler( elem, name, isXML ) {
384+
var val;
385+
return isXML ?
386+
undefined :
387+
(val = elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 ));
385388
}
386389

387390
/**
388391
* Uses defaultValue to retrieve value in IE6/7
389392
* @param {Element} elem
390393
* @param {String} name
391394
*/
392-
function valueHandler( elem ) {
393-
// Ignore the value *property* on inputs by using defaultValue
394-
// Fallback to Sizzle.attr by returning undefined where appropriate
395-
// XML does not need to be checked as this will not be assigned for XML documents
396-
if ( elem.nodeName.toLowerCase() === "input" ) {
397-
return elem.defaultValue;
398-
}
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);
399402
}
400403

401404
/**
@@ -536,16 +539,12 @@ setDocument = Sizzle.setDocument = function( node ) {
536539
});
537540

538541
// Support: IE<9
539-
// Retrieving value should defer to defaultValue
540-
support.input = assert(function( div ) {
541-
div.innerHTML = "<input>";
542+
// Verify that getAttribute is accurate for "value" specifically
543+
addHandle( "value", valueHandler, support.attributes && assert(function( div ) {
544+
div.innerHTML = "<input/>";
542545
div.firstChild.setAttribute( "value", "" );
543546
return div.firstChild.getAttribute( "value" ) === "";
544-
});
545-
546-
// IE6/7 still return empty string for value,
547-
// but are actually retrieving the property
548-
addHandle( "value", valueHandler, support.attributes && support.input );
547+
}) );
549548

550549
/* getElement(s)By*
551550
---------------------------------------------------------------------- */

0 commit comments

Comments
 (0)