Skip to content

Commit

Permalink
重构$.filter,只要回调返回能转为真值的情况就收集该元素
Browse files Browse the repository at this point in the history
  • Loading branch information
RubyLouvre committed Jan 28, 2013
1 parent 23b9ae2 commit 0afcbc2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lang.js
Expand Up @@ -153,8 +153,8 @@ define("lang", Array.isArray ? ["mass"] : ["$lang_fix"], function($) {
filter: function(obj, fn, scope) {
for(var i = 0, n = obj.length, ret = []; i < n; i++) {
var val = fn.call(scope || obj[i], obj[i], i);
if(val === true) {
ret[ret.length] = obj[i]
if(!!val) {
ret[ret.length] = obj[i];
}
}
return ret;
Expand Down

0 comments on commit 0afcbc2

Please sign in to comment.