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

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

Closed
b01 opened this issue Jan 13, 2016 · 4 comments

Comments

@b01
Copy link

b01 commented Jan 13, 2016

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!");
}
@domenic
Copy link
Member

domenic commented Jan 13, 2016

This should be fixed in master, will test and get back to you...

@domenic
Copy link
Member

domenic commented Jan 15, 2016

@Sebmaster this looks to be not fixed and also the current situation is confusing. WindowEventHandlers does not have an implementation at all, so won't that break the onxyzs on body? It also isn't mixed in to Window. (Nor is GlobalEventHandlers.)

A quick fix might be to comment out all of the contents of WindowEventHandlers.idl and GlobalEventHandlers.idl as TODOs. What do you think?

@Sebmaster
Copy link
Member

To clarify in this issue: There is no change to this in master and this should behave as it did in 7.2.x, so we won't have to change anything immediately. To solve this perfectly we'll need to properly implement inline event handlers. It's a change that will come soon, but probably not before the next major release.

domenic pushed a commit that referenced this issue May 21, 2017
This exposes getters/setters for all the on[event] properties on the prototype, thus closing #1354. It also slots them into the correct place in the attribute list upon setting, thus closing #696. Along the way, it generally makes all the event handler processing per-spec; we pass many more web platform tests in this area.
@Sebmaster
Copy link
Member

Fixed in 5f3cbd6.

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

No branches or pull requests

3 participants