javascriptobjectfirefox-addonmozilla

How can I avoid state of "TypeError: can't access dead object" in my Firefox add-on?


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?


Solution

  • 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