Commit f25eedf3 authored by John Resig's avatar John Resig

Restrict the attr quick setters to only methods that specifically ask for the...

Restrict the attr quick setters to only methods that specifically ask for the functionality. Fixes #5612.
parent 1a4d1904
......@@ -200,12 +200,27 @@ jQuery.each({
});
jQuery.extend({
attrFn: {
val: true,
addClass: true,
css: true,
html: true,
text: true,
append: true,
prepend: true,
data: true,
width: true,
height: true,
offset: true
},
attr: function( elem, name, value ) {
// don't set attributes on text and comment nodes
if (!elem || elem.nodeType == 3 || elem.nodeType == 8) {
return undefined;
}
if ( name in jQuery.fn && name !== "attr" ) {
if ( name in jQuery.attrFn ) {
return jQuery(elem)[name](value);
}
......
......@@ -885,6 +885,10 @@ jQuery.each( ("blur focus load resize scroll unload click dblclick " +
jQuery.fn[ name ] = function( fn ) {
return fn ? this.bind( name, fn ) : this.trigger( name );
};
if ( jQuery.fnAttr ) {
jQuery.fnAttr[ name ] = true;
}
});
// Prevent memory leaks in IE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment