Permalink
Browse files

Build for: Added opts param to setAttrs(attrs, opts), to match set(at…

…tr, opts). Fixes #2531617
  • Loading branch information...
1 parent 07446cd commit 4f29df5f2886903e9207492d34dc845b0bf3aa1b @sdesai committed May 22, 2012
@@ -86,6 +86,7 @@ YUI.add('attribute-events', function(Y) {
*
* @method setAttrs
* @param {Object} attrs An object with attributes name/value pairs.
+ * @param {Object} opts Properties to mix into the event payload. These are shared and mixed into each set
* @return {Object} A reference to the host object.
* @chainable
*/
@@ -94,6 +95,25 @@ YUI.add('attribute-events', function(Y) {
},
/**
+ * Implementation behind the public setAttrs method, to set multiple attribute values.
+ *
+ * @method _setAttrs
+ * @protected
+ * @param {Object} attrs An object with attributes name/value pairs.
+ * @param {Object} opts Properties to mix into the event payload. These are shared and mixed into each set
+ * @return {Object} A reference to the host object.
+ * @chainable
+ */
+ _setAttrs : function(attrs, opts) {
+ for (var attr in attrs) {
+ if ( attrs.hasOwnProperty(attr) ) {
+ this.set(attr, attrs[attr], opts);
+ }
+ }
+ return this;
+ },
+
+ /**
* Utility method to help setup the event payload and fire the attribute change event.
*
* @method _fireAttrChange
@@ -1 +1 @@
-YUI.add("attribute-events",function(e){var f=e.EventTarget,d="Change",a="broadcast",c="published";function b(){this._ATTR_E_FACADE={};f.call(this,{emitFacade:true});}b._ATTR_CFG=[a];b.prototype={set:function(g,i,h){return this._setAttr(g,i,h);},_set:function(g,i,h){return this._setAttr(g,i,h,true);},setAttrs:function(g,h){return this._setAttrs(g,h);},_fireAttrChange:function(o,n,k,j,g){var q=this,m=o+d,i=q._state,p,l,h;if(!i.get(o,c)){h={queuable:false,defaultTargetOnly:true,defaultFn:q._defAttrChangeFn,silent:true};l=i.get(o,a);if(l!==undefined){h.broadcast=l;}q.publish(m,h);i.add(o,c,true);}p=(g)?e.merge(g):q._ATTR_E_FACADE;p.attrName=o;p.subAttrName=n;p.prevVal=k;p.newVal=j;q.fire(m,p);},_defAttrChangeFn:function(g){if(!this._setAttrVal(g.attrName,g.subAttrName,g.prevVal,g.newVal)){g.stopImmediatePropagation();}else{g.newVal=this.get(g.attrName);}}};e.mix(b,f,false,null,1);e.AttributeEvents=b;},"@VERSION@",{requires:["event-custom"]});
+YUI.add("attribute-events",function(e){var f=e.EventTarget,d="Change",a="broadcast",c="published";function b(){this._ATTR_E_FACADE={};f.call(this,{emitFacade:true});}b._ATTR_CFG=[a];b.prototype={set:function(g,i,h){return this._setAttr(g,i,h);},_set:function(g,i,h){return this._setAttr(g,i,h,true);},setAttrs:function(g,h){return this._setAttrs(g,h);},_setAttrs:function(h,i){for(var g in h){if(h.hasOwnProperty(g)){this.set(g,h[g],i);}}return this;},_fireAttrChange:function(o,n,k,j,g){var q=this,m=o+d,i=q._state,p,l,h;if(!i.get(o,c)){h={queuable:false,defaultTargetOnly:true,defaultFn:q._defAttrChangeFn,silent:true};l=i.get(o,a);if(l!==undefined){h.broadcast=l;}q.publish(m,h);i.add(o,c,true);}p=(g)?e.merge(g):q._ATTR_E_FACADE;p.attrName=o;p.subAttrName=n;p.prevVal=k;p.newVal=j;q.fire(m,p);},_defAttrChangeFn:function(g){if(!this._setAttrVal(g.attrName,g.subAttrName,g.prevVal,g.newVal)){g.stopImmediatePropagation();}else{g.newVal=this.get(g.attrName);}}};e.mix(b,f,false,null,1);e.AttributeEvents=b;},"@VERSION@",{requires:["event-custom"]});
@@ -86,6 +86,7 @@ YUI.add('attribute-events', function(Y) {
*
* @method setAttrs
* @param {Object} attrs An object with attributes name/value pairs.
+ * @param {Object} opts Properties to mix into the event payload. These are shared and mixed into each set
* @return {Object} A reference to the host object.
* @chainable
*/
@@ -94,6 +95,25 @@ YUI.add('attribute-events', function(Y) {
},
/**
+ * Implementation behind the public setAttrs method, to set multiple attribute values.
+ *
+ * @method _setAttrs
+ * @protected
+ * @param {Object} attrs An object with attributes name/value pairs.
+ * @param {Object} opts Properties to mix into the event payload. These are shared and mixed into each set
+ * @return {Object} A reference to the host object.
+ * @chainable
+ */
+ _setAttrs : function(attrs, opts) {
+ for (var attr in attrs) {
+ if ( attrs.hasOwnProperty(attr) ) {
+ this.set(attr, attrs[attr], opts);
+ }
+ }
+ return this;
+ },
+
+ /**
* Utility method to help setup the event payload and fire the attribute change event.
*
* @method _fireAttrChange

0 comments on commit 4f29df5

Please sign in to comment.