lib/kissy/5.0.0-alpha.3/lib/build/event/custom.js
function (cfg) {
            var groupsRe, self = this, fn = cfg.fn, context = cfg.context, currentTarget = self.currentTarget, observers = self.observers, groups = cfg.groups;
            if (!observers.length) {
                return;
            }
            if (groups) {
                groupsRe = Utils.getGroupsRe(groups);
            }
            var i, j, t, observer, observerContext, len = observers.length;    // 移除 fn
            // 移除 fn
            if (fn || groupsRe) {
                context = context || currentTarget;
                for (i = 0, j = 0, t = []; i < len; ++i) {
                    observer = observers[i];
                    observerContext = observer.context || currentTarget;
                    if (context !== observerContext || // 指定了函数，函数不相等，保留
                        fn && fn !== observer.fn || // 指定了删除的某些组，而该 observer 不属于这些组，保留，否则删除
                        groupsRe && !observer.groups.match(groupsRe)) {
                        t[j++] = observer;
                    }
                }
                self.observers = t;
            } else {
                // 全部删除
                self.reset();
            }    // does not need to clear memory if customEvent has no observer
                 // customEvent has defaultFn .....!
                 // self.checkMemory();
        }
function (cfg) {
            var groupsRe, self = this, fn = cfg.fn, context = cfg.context, currentTarget = self.currentTarget, observers = self.observers, groups = cfg.groups;
            if (!observers.length) {
                return;
            }
            if (groups) {
                groupsRe = Utils.getGroupsRe(groups);
            }
            var i, j, t, observer, observerContext, len = observers.length;    // 移除 fn
            // 移除 fn
            if (fn || groupsRe) {
                context = context || currentTarget;
                for (i = 0, j = 0, t = []; i < len; ++i) {
                    observer = observers[i];
                    observerContext = observer.context || currentTarget;
                    if (context !== observerContext || // 指定了函数，函数不相等，保留
                        fn && fn !== observer.fn || // 指定了删除的某些组，而该 observer 不属于这些组，保留，否则删除
                        groupsRe && !observer.groups.match(groupsRe)) {
                        t[j++] = observer;
                    }
                }
                self.observers = t;
            } else {
                // 全部删除
                self.reset();
            }    // does not need to clear memory if customEvent has no observer
                 // customEvent has defaultFn .....!
                 // self.checkMemory();
        }
function ( cfg ) { var groupsRe , self = this , fn = cfg . fn , context = cfg . context , currentTarget = self . currentTarget , observers = self . observers , groups = cfg . groups ; if ( ! observers . length ) { return ; } if ( groups ) { groupsRe = Utils . getGroupsRe ( groups ) ; } var i , j , t , observer , observerContext , len = observers . length ; // 移除 fn // 移除 fn if ( fn || groupsRe ) { context = context || currentTarget ; for ( i = 0 , j = 0 , t = [ ] ; i < len ; ++ i ) { observer = observers [ i ] ; observerContext = observer . context || currentTarget ; if ( context !== observerContext || // 指定了函数，函数不相等，保留 fn && fn !== observer . fn || // 指定了删除的某些组，而该 observer 不属于这些组，保留，否则删除 groupsRe && ! observer . groups . match ( groupsRe ) ) { t [ j ++ ] = observer ; } } self . observers = t ; } else { // 全部删除 self . reset ( ) ; } // does not need to clear memory if customEvent has no observer // customEvent has defaultFn .....! // self.checkMemory(); }
remove some observers from current event 's observers by observer config param
@param {Object} cfg {@link KISSY.Event.CustomEvent.Observer} 's config
remove some observers from current event s observers by observer config param