lib/kissy/5.0.0-alpha.3/build/attribute-debug.js
function (name, value, opts) {
            var self = this, e;
            if (typeof name !== 'string') {
                opts = value;
                opts = opts || {};
                var all = Object(name), attrs = [], errors = [];
                for (name in all) {
                    // bulk validation
                    // if any one failed,all values are not set
                    if ((e = validate(self, name, all[name], all)) !== undefined) {
                        errors.push(e);
                    }
                }
                if (errors.length) {
                    if (opts.error) {
                        opts.error(errors);
                    }
                    return FALSE;
                }
                for (name in all) {
                    setInternal(self, name, all[name], opts, attrs);
                }
                var attrNames = [], prevVals = [], newVals = [], subAttrNames = [];
                util.each(attrs, function (attr) {
                    prevVals.push(attr.prevVal);
                    newVals.push(attr.newVal);
                    attrNames.push(attr.attrName);
                    subAttrNames.push(attr.subAttrName);
                });
                if (attrNames.length) {
                    __fireAttrChange(self, '', '*', prevVals, newVals, subAttrNames, attrNames, opts.data);
                }
                return self;
            }
            opts = opts || {};    // validator check
            // validator check
            e = validate(self, name, value);
            if (e !== undefined) {
                if (opts.error) {
                    opts.error(e);
                }
                return FALSE;
            }
            return setInternal(self, name, value, opts);
        }
function (name, value, opts) {
            var self = this, e;
            if (typeof name !== 'string') {
                opts = value;
                opts = opts || {};
                var all = Object(name), attrs = [], errors = [];
                for (name in all) {
                    // bulk validation
                    // if any one failed,all values are not set
                    if ((e = validate(self, name, all[name], all)) !== undefined) {
                        errors.push(e);
                    }
                }
                if (errors.length) {
                    if (opts.error) {
                        opts.error(errors);
                    }
                    return FALSE;
                }
                for (name in all) {
                    setInternal(self, name, all[name], opts, attrs);
                }
                var attrNames = [], prevVals = [], newVals = [], subAttrNames = [];
                util.each(attrs, function (attr) {
                    prevVals.push(attr.prevVal);
                    newVals.push(attr.newVal);
                    attrNames.push(attr.attrName);
                    subAttrNames.push(attr.subAttrName);
                });
                if (attrNames.length) {
                    __fireAttrChange(self, '', '*', prevVals, newVals, subAttrNames, attrNames, opts.data);
                }
                return self;
            }
            opts = opts || {};    // validator check
            // validator check
            e = validate(self, name, value);
            if (e !== undefined) {
                if (opts.error) {
                    opts.error(e);
                }
                return FALSE;
            }
            return setInternal(self, name, value, opts);
        }
function ( name , value , opts ) { var self = this , e ; if ( typeof name !== 'string' ) { opts = value ; opts = opts || { } ; var all = Object ( name ) , attrs = [ ] , errors = [ ] ; for ( name in all ) { // bulk validation // if any one failed,all values are not set if ( ( e = validate ( self , name , all [ name ] , all ) ) !== undefined ) { errors . push ( e ) ; } } if ( errors . length ) { if ( opts . error ) { opts . error ( errors ) ; } return FALSE ; } for ( name in all ) { setInternal ( self , name , all [ name ] , opts , attrs ) ; } var attrNames = [ ] , prevVals = [ ] , newVals = [ ] , subAttrNames = [ ] ; util . each ( attrs , function ( attr ) { prevVals . push ( attr . prevVal ) ; newVals . push ( attr . newVal ) ; attrNames . push ( attr . attrName ) ; subAttrNames . push ( attr . subAttrName ) ; } ) ; if ( attrNames . length ) { __fireAttrChange ( self , '' , '*' , prevVals , newVals , subAttrNames , attrNames , opts . data ) ; } return self ; } opts = opts || { } ; // validator check // validator check e = validate ( self , name , value ) ; if ( e !== undefined ) { if ( opts . error ) { opts . error ( e ) ; } return FALSE ; } return setInternal ( self , name , value , opts ) ; }
Sets the value of an attribute.
@param {String|Object} name attribute 's name or attribute name and value map
@param [value] attribute 's value
@param {Object} [opts] some options
@param {Boolean} [opts.silent] whether fire change event
@param {Function} [opts.error] error handler
@return {Boolean} whether pass validator
Sets the value of an attribute .