mirror of
https://github.com/jquery/jquery.git
synced 2026-01-31 16:07:59 -05:00
Attributes: Avoid infinite recursion on non-lowercase attribute getters
Attribute hooks are determined for the lowercase versions of attribute names but this has not been reflected in the bool attribute hooks. The code that temporarily removed a handler to avoid an infinite loop was removing an incorrect handler causing stack overflow. Fixes gh-3133 Refs gh-2914 Refs gh-2916 Closes gh-3134
This commit is contained in:
@@ -117,16 +117,18 @@ jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name )
|
||||
var getter = attrHandle[ name ] || jQuery.find.attr;
|
||||
|
||||
attrHandle[ name ] = function( elem, name, isXML ) {
|
||||
var ret, handle;
|
||||
var ret, handle,
|
||||
lowercaseName = name.toLowerCase();
|
||||
|
||||
if ( !isXML ) {
|
||||
|
||||
// Avoid an infinite loop by temporarily removing this function from the getter
|
||||
handle = attrHandle[ name ];
|
||||
attrHandle[ name ] = ret;
|
||||
handle = attrHandle[ lowercaseName ];
|
||||
attrHandle[ lowercaseName ] = ret;
|
||||
ret = getter( elem, name, isXML ) != null ?
|
||||
name.toLowerCase() :
|
||||
lowercaseName :
|
||||
null;
|
||||
attrHandle[ name ] = handle;
|
||||
attrHandle[ lowercaseName ] = handle;
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user