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 public interface #807

Closed
jonathanKingston opened this issue Sep 10, 2018 · 5 comments
Closed

web-sys public interface #807

jonathanKingston opened this issue Sep 10, 2018 · 5 comments
Labels
web-sys Issues related to the `web-sys` crate

Comments

@jonathanKingston
Copy link
Contributor

I would like the ability to figure out the relationship from webidl files and investigate the properties, and interfaces an element exposes.

The use-case I am trying to solve is essentially wrapping up the interfaces and neaten the API a little. That way I can wrap that "input" creates HTMLInputElement and also implements HTMLElement

I started by parsing webidl myself however it will end up requiring a lot of reimplementation of the web-sys crate. I ended up having to manipulate type into _type, accessKey to access_key and HTMLDivElement to HtmlDivElement

I'm not sure if it makes sense to output the backend format instead, in a way I kind of need a mapping of the webidl to the web_sys.

To be useful I would need something like an interim data structure like the following:

HtmlInputElement {
  webidl_name: "HTMLInputElement",
  interfaces: ["HTMLElement", "Element", "EventTarget"],
  properties: [
    {
      name: "id",
      setter: {name: "set_id", arguments: [...]}
    }
  ]
}

Having the ast that is about to be written to file might be a simpler way to code generate and wrap around the Element interfaces.

@alexcrichton
Copy link
Contributor

This seems like a good idea to me! I think we could pretty reasonably basically have a public crate that sits on top of web-sys's webidls and is run by web-sys's build script. That could have a conservative API which provides access to all of the internals of what we do, basically iterating over the program imports that we generate

@alexcrichton
Copy link
Contributor

I'm going to close this since it's been quiet for some time, it's still possible to add this if necessary though!

@cortopy
Copy link

cortopy commented Mar 1, 2020

@alexandrestein I've just landed here from rust-lang/rls#1489. It seems like this would be required to have a good RLS experience with web-sys

@Pauan
Copy link
Contributor

Pauan commented Mar 1, 2020

@cortopy Although it wasn't intended to fix RLS, this PR does indirectly fix it, because it removes the build.rs script.

@dancespiele
Copy link

@Pauan In my case I have the last version of wasm-bindgen(0.2.59) and web_sys(0.3.36) and I don't get autocomplete in vscode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
web-sys Issues related to the `web-sys` crate
Projects
None yet
Development

No branches or pull requests

6 participants