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

How can I get a reference to the document object? #71

Closed
akritrime opened this issue Mar 20, 2018 · 4 comments
Closed

How can I get a reference to the document object? #71

akritrime opened this issue Mar 20, 2018 · 4 comments

Comments

@akritrime
Copy link

On js side, document or rather window.document provides the reference to the document object contained in the current window. Is there any way I can access that document using wasm_bindgen? Or do I need to write a js file exposes the required functionality of the document API?

@alexcrichton
Copy link
Contributor

A good question!

This wasn't actually super easy to do before so I've been thinking a bit and have decided to tweak how some functions are accessed exposed. I've now written up an example of how to do this as well!

For now that functionality is only available on master, but I'll publish 0.2 soon with that!

@alexcrichton
Copy link
Contributor

Please let me know though if the example is confusing or otherwise needs to be fleshed out more, I'd love to expand it!

@akritrime
Copy link
Author

@alexcrichton That example is quite enough. One doubt though, why can't JsValue be used instead of a new type of HTMLDocument?

@alexcrichton
Copy link
Contributor

Ah currently this is just the main way to add methods to an otherwise "bland JsValue", but internally it's just a JsValue so I pushed up alexcrichton@fc81d8f which allows interconversion

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

2 participants