diff options
author | Timmy Willison <timmywillisn@gmail.com> | 2013-08-28 12:12:37 -0400 |
---|---|---|
committer | Timmy Willison <timmywillisn@gmail.com> | 2013-08-28 12:23:54 -0400 |
commit | 01d5a1a1c9d5469057cafc5a2b27668d0e04ad22 (patch) | |
tree | 8aecfe90ba0ec337ba4a59c9340a425adbe0673a /src | |
parent | a7a3b8ce1b602f4e87539e934005875e648be192 (diff) | |
download | jquery-01d5a1a1c9d5469057cafc5a2b27668d0e04ad22.tar.gz jquery-01d5a1a1c9d5469057cafc5a2b27668d0e04ad22.zip |
Fix for custom attr handles duck-punching the boolean attr handle
Conflicts:
src/attributes/attr.js
Diffstat (limited to 'src')
-rw-r--r-- | src/attributes/attr.js | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/src/attributes/attr.js b/src/attributes/attr.js index 202c7028b..170e6a39e 100644 --- a/src/attributes/attr.js +++ b/src/attributes/attr.js @@ -6,7 +6,8 @@ define([ "../support" ], function( jQuery, rnotwhite, strundefined ) { -var nodeHook, boolHook; +var nodeHook, boolHook, + attrHandle = jQuery.expr.attrHandle; jQuery.fn.extend({ attr: function( name, value ) { @@ -120,23 +121,19 @@ boolHook = { } }; jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) { - var getter = jQuery.expr.attrHandle[ name ] || jQuery.find.attr; - - jQuery.expr.attrHandle[ name ] = function( elem, name, isXML ) { - var fn = jQuery.expr.attrHandle[ name ], - ret = isXML ? - undefined : - /* jshint eqeqeq: false */ - // Temporarily disable this handler to check existence - (jQuery.expr.attrHandle[ name ] = undefined) != - getter( elem, name, isXML ) ? - - name.toLowerCase() : - null; - - // Restore handler - jQuery.expr.attrHandle[ name ] = fn; - + var getter = attrHandle[ name ] || jQuery.find.attr; + + attrHandle[ name ] = function( elem, name, isXML ) { + var ret, handle; + if ( !isXML ) { + // Avoid an infinite loop by temporarily removing this function from the getter + handle = attrHandle[ name ]; + attrHandle[ name ] = ret; + ret = getter( elem, name, isXML ) != null ? + name.toLowerCase() : + null; + attrHandle[ name ] = handle; + } return ret; }; }); |