Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

打印具备 deprecated 方法的对象时会报错 #14

Closed
jareguo opened this issue Aug 15, 2016 · 6 comments
Closed

打印具备 deprecated 方法的对象时会报错 #14

jareguo opened this issue Aug 15, 2016 · 6 comments

Comments

@jareguo
Copy link

jareguo commented Aug 15, 2016

API 升级后,经常会保留一些旧版本的 API 接口作为过渡,例如

Object.defineProperty(Sprite.prototype, 'cascade', {
  get: function () {
    console.error('Sprite.cascade is deprecated, use Node.cascade please.');
    return this._realCascade;
  },
  enumerable: false
})

然后如果用户尝试输出 console.log(sprite),就会看到多了上面的报错:'Sprite.cascade is deprecated, use Node.cascade please.'

请问该怎么解决这类问题?

@surunzi
Copy link
Member

surunzi commented Aug 16, 2016

v1.0.8(本周内更新)会暴露filter接口,可以调用屏蔽一些指定的Log。

eruda.get('console').filter(function (log)
{
    return !(log.type === 'error' && /deprecated(.|\n)*stringify/.test(log.src.stack));
});

@jareguo
Copy link
Author

jareguo commented Aug 17, 2016

cool!

@surunzi
Copy link
Member

surunzi commented Aug 21, 2016

Console面板的代码重构中,同时增加单元测试,字符串%d%o替换、CSS样式支持、表格输出等新功能及相关接口文档,版本更新推迟。

@jareguo
Copy link
Author

jareguo commented Aug 22, 2016

嗯,没事…… 这边我先绕过了

@surunzi
Copy link
Member

surunzi commented Aug 27, 2016

已更新1.1.0版(相关接口文档更新中),可通过以下方法绕过:

1、设置filter

eruda.get('console').filter(function (log)
{
    return !(log.type === 'error' && /deprecated(.|\n)*stringify/.test(log.src.stack));
});

2、禁止访问不可枚举属性

eruda.get('console').config.set('displayUnenumerable', false);

3、禁止访问Getter方法(默认)

eruda.get('console').config.get('displayGetterVal', false);

2、3可以设置面板里手动开启关闭

@jareguo
Copy link
Author

jareguo commented Aug 29, 2016

👍 很棒

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants