aralejs / events

Events Utility
aralejs.org/events/
34 stars 41 forks source link

IE6-8 不支持Object.keys Array.forEach #20

Open iceman1212 opened 9 years ago

iceman1212 commented 9 years ago

copy了ieBetter.js的部分代码解决了此问题 https://github.com/zhangxinxu/ieBetter.js/blob/master/ieBetter.js https://github.com/zhangxinxu/ieBetter.js

if (!Object.keys) {
    Object.keys = function(o) {
        if (o !== Object(o)) {
            throw new TypeError('Object.keys called on a non-object');
        }
        var k=[], p;
        for (p in o) {
            if (Object.prototype.hasOwnProperty.call(o,p)) {
                k.push(p);
            }
        }
        return k;
    };
}

  if (typeof Array.prototype.forEach != "function") {
    Array.prototype.forEach = function (fn, scope) {
        var i, len;
        for (i = 0, len = this.length; i < len; ++i) {
            if (i in this) {
                fn.call(scope, this[i], i, this);
            }
        }
           };
}
afc163 commented 9 years ago

这个组件是被改乱了,现在也没人负责。唉

iceman1212 commented 9 years ago

aralejs 组件 都没人负责吗? 我还想在项目中使用呢

afc163 commented 9 years ago

@popomore

army8735 commented 9 years ago

感觉是时候推出es6版本了。

popomore commented 9 years ago

稳定版没有啊,master 那个 commit 要不要回滚啊,不要的话 @army8735 改改吧

afc163 commented 9 years ago

https://github.com/aralejs/events/blob/spm2/src/events.js

popomore commented 9 years ago

也没问题

afc163 commented 9 years ago

话说 chair 里线上用的到底是哪个版本啊?现在的版本明显会报错啊

popomore commented 9 years ago

1.2.0 吧,哪行代码会报错?

afc163 commented 9 years ago

forEach ?

popomore commented 9 years ago

没搜到 forEach 的代码

afc163 commented 9 years ago

https://github.com/aralejs/events/blob/7fd77c11015d3db7942434d43107cb9c1e8648bc/events.js#L154

popomore commented 9 years ago

上面不是说了么,这个是 master,不是稳定版

afc163 commented 9 years ago

原来是这个改动有问题:https://github.com/aralejs/events/commit/7fd77c11015d3db7942434d43107cb9c1e8648bc

我以为是之前的遗留问题。这个 commit 修改掉吧。