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

web-sys's API around Window seems to be wrong #834

Closed
upsuper opened this issue Sep 16, 2018 · 3 comments
Closed

web-sys's API around Window seems to be wrong #834

upsuper opened this issue Sep 16, 2018 · 3 comments

Comments

@upsuper
Copy link

upsuper commented Sep 16, 2018

Currently, web-sys provides a Window type and use static functions to access objects and functions in the current global.

This seems to be conceptually wrong. Window is an object, and there can be multiple independent Window around, so the current global is just one Window object.

I suggest it provide a top level function window() which returns a Option<Window> instead (Option because the code may run in worker / worklet global where window isn't available).

@upsuper
Copy link
Author

upsuper commented Sep 16, 2018

And it seems to me that to reasonably implement Window.open as well as HTMLIFrameElement.contentWindow, there needs to be proper Window object support.

@fitzgen
Copy link
Member

fitzgen commented Sep 17, 2018

Gah -- we hadn't considered multiple Windows when we were thinking about how to bind global methods. I think this is a blocker for publishing.

+cc @alexcrichton

@fitzgen fitzgen mentioned this issue Sep 17, 2018
19 tasks
@alexcrichton
Copy link
Contributor

Makes sense to me, I'll work on reverting #761

alexcrichton added a commit to alexcrichton/wasm-bindgen that referenced this issue Sep 17, 2018
This is intended to address rustwasm#834 where we don't actually want methods scoped
like this! Instead we'll provide one unique accessor for the `window` object
itself.
alexcrichton added a commit to alexcrichton/wasm-bindgen that referenced this issue Sep 18, 2018
This is intended to address rustwasm#834 where we don't actually want methods scoped
like this! Instead we'll provide one unique accessor for the `window` object
itself.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants