You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Woops, I just learnd this is actually a well-known issue; and thanks for the pointers to the existing pragmatic approaches that are basically relying on unchecked_into().
Skimming through the previous discussions in the links, I do share the same view that a more fundamental fix would be for us to do something about instanceof.
The root problem has turned out to be not only about web_sys::window(). I am working on some global-agnostic code where I just want to perform some simple checks like
and they all are failing with similar errors thrown when in a 'wrong' context. With the sought-after fundamental fix in mind, I'd like to open a separate issue when I come up with something worth sharing.
And for now, I'm closing this particular issue on resolving global to Window.
Describe the Bug
Calling
web_sys::window()
in a Web Worker throws an unexpected runtime error.In this case, according to its signature (
pub fn window() -> Option<Window>
), I expect it to returnNone
instead.References:
Steps to Reproduce
Expected Behavior
web_sys::window()
returnsNone
. No runtime errors reported in the Developer Console .Actual Behavior
Get an Uncaught ReferenceError as in the above screenshot.
Additional Context
n/a
The text was updated successfully, but these errors were encountered: