Skip to content

JSDOM sets the default value of window.onhashchange to undefined which breaks feature detection. #1354

@b01

Description

@b01

Not possible to use feature detection of onhashchange in jsdom 7.2.1 like so:

if ("onhashchange" in window) {
    console.log("The browser supports the hashchange event!");
}

The message does not print from the code above. However, this is my work-a-round for now:

// HACK: When in a browser, the default value for onhashchange is null, but jsdom sets it to undefined.
window.onhashchange = null;
if ("onhashchange" in window) {
    console.log("The browser supports the hashchange event!");
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions