我该如何避免“TypeError:无法访问死对象”的状态?在我的Firefox附加? [英] How can I avoid state of "TypeError: can't access dead object" in my Firefox add-on?

查看:167
本文介绍了我该如何避免“TypeError:无法访问死对象”的状态?在我的Firefox附加?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看来检查 null 的作品,但它是一个正确的方法吗?我怎样才能正确地检查该对象是不是死了?死对象的定义在哪里?

解决方案

死对象意味着一个对象,其父文档已被销毁,被删除,以消除附加组件的内存泄漏。所以你可以检查这个元素,如下所示:

pre $ if(typeof some_element!=='undefined'){
//不是死的

请参阅 $ / $>

It seems checking against null works, but is it a correct method? How can I correctly check that object is not dead? And where is the definition of dead object?

Dead object would mean an object whose parent document has been destroyed, and the references are removed to eliminate memory leaks in add-ons. So you could check for the element, as:

if( typeof some_element !== 'undefined') {
    //its not dead
}

See Dead Object Reference

这篇关于我该如何避免“TypeError:无法访问死对象”的状态?在我的Firefox附加?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆