Skip to content

window defensiveness #747

Closed
Closed
@LewisJEllis

Description

@LewisJEllis

In these initialization lines:

var _window = typeof window !== 'undefined' ? window : undefined;
var _document = _window && _window.document;

the second line appears to be defensive against the possibility that window is undefined (note also that unless I'm mistaken, the first line is semantically equivalent to var _window = window;).

Later lines, however, are not similarly defensive, with

this._originalConsole = _window.console || {};
...
this._location = _window.location;

in the Raven constructor and

var RavenConfig = _window.RavenConfig;

in afterLoad. We also do

var _Raven = window.Raven;

in singleton.js.

I know we care about working if document doesn't exist, but do we care about being defensive against window not existing? If so, we should also be defensive in these other spots; if not, we shouldn't bother pretending in the _document declaration. Either way, we can simplify the _window declaration.

/cc @benvinegar

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions