]> source.dussan.org Git - jquery.git/commitdiff
Restrict the attr quick setters to only methods that specifically ask for the functio...
authorJohn Resig <jeresig@gmail.com>
Thu, 10 Dec 2009 05:28:33 +0000 (21:28 -0800)
committerJohn Resig <jeresig@gmail.com>
Thu, 10 Dec 2009 05:28:33 +0000 (21:28 -0800)
src/attributes.js
src/event.js

index 8080af83d2755430b8b7c3d1fc93839233bff1e0..fb5b16bcd672b7cf5d773055b19c129b4f99dbab 100644 (file)
@@ -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);
                }
 
index f7668965fe580c55f894ce7f0bd378c68a31921e..a32f0339c8d9829e7b97b4f888fa9d682e8db588 100644 (file)
@@ -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