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

Events API #51

Closed
goatandsheep opened this issue Feb 12, 2019 · 17 comments
Closed

Events API #51

goatandsheep opened this issue Feb 12, 2019 · 17 comments
Assignees

Comments

@goatandsheep
Copy link

Is there a way to show events fired?

@aeschli
Copy link
Contributor

aeschli commented Feb 12, 2019

What kind of events?

@goatandsheep
Copy link
Author

@aeschli sorry for my lack of clarity. I mean for events fired by the elements, particularly custom elements

@aeschli
Copy link
Contributor

aeschli commented Feb 12, 2019

Please give some examples... Maybe a small sample code what you expect to see (hovers, code completion...)

@goatandsheep
Copy link
Author

I think that @event is a great example for how it could be denoted. The hover for jsdoc is really good. I think the hover could either:

  • simply have the event in the description of the element
  • treat it like an attribute with the name on<custom-event-name>

@aeschli
Copy link
Contributor

aeschli commented Feb 13, 2019

I guess this is about JavaScript/TypeScript then. Still I don't know what exactly you suggest to improve or add. Something for VSCode to show, or a TypeScript language feature?

@aeschli aeschli assigned mjbvz and unassigned aeschli Feb 13, 2019
@goatandsheep
Copy link
Author

Similar to this issue WICG/webcomponents#776 that addresses displaying details about custom components, I would add to it to show events when writing HTML

@aeschli aeschli assigned octref and unassigned mjbvz Feb 13, 2019
@octref
Copy link
Contributor

octref commented Feb 13, 2019

If all you want is onMyEvent as an attribute completion, why can't you use the existing globalAttributes? https://github.com/Microsoft/vscode-html-languageservice/blob/master/docs/customData.md

@goatandsheep
Copy link
Author

@octref because the type of input is always function, but what's important about documenting events is not the type of input but the type of data from the event

@octref
Copy link
Contributor

octref commented Feb 13, 2019

We don't do any type-checking diagnostic for HTML attribute value, at least not on the HTML service.

What Language Feature exactly do you want for events?

@aeschli
Copy link
Contributor

aeschli commented Mar 29, 2019

ping @goatandsheep
Please explain how support for events would look like in the UI.
Maybe a small sample code along with what you expect to see (hovers, code completion...)

@goatandsheep
Copy link
Author

@aeschli I was thinking about how when you do event handling in the HTML, your input for an oncustombind would be a callback function, so the documentation for an event should be like any other Javascript function, i.e. JsDoc. However, as @octref mentioned, that would be checked in Javascript, not HTML, anyways. So it would likely be enough to simply add onevent with a description of the event and the type being Function.

It's fine if referring to events in the hovers doesn't require code changes, but we should encourage use and show examples of how it would be used.

@octref
Copy link
Contributor

octref commented Mar 31, 2019

Due to the myriad ways people load their JS it's impossible to check where the value of myevent="something" comes from. I don't want Schrodinger's diagnostics for myevent="window.foo", so no.

@octref octref closed this as completed Mar 31, 2019
@goatandsheep
Copy link
Author

goatandsheep commented May 27, 2019

@octref would this standard for documenting custom elements using jsdocs by @runem still require a myriad of ways to diagnose the values?

@octref
Copy link
Contributor

octref commented May 28, 2019

You should ask them to generate data of this format: https://github.com/microsoft/vscode-html-languageservice/blob/master/docs/customData.md.

@goatandsheep
Copy link
Author

@octref thank you for the suggestion! They actually already do generate data of that format, but the format is quite rudimentary as it doesn't let you list events, slots, nor cssprops. I'm thinking, instead of trying to interpret each of the jsdoc tags and every future request that may come, is there a way to just show various tags as hover comments?

@octref
Copy link
Contributor

octref commented May 28, 2019

No. Each item's description is shown on hover. That's all. Ask them to put whatever they want into the description.

@goatandsheep
Copy link
Author

That's perfect. Thanks @octref !

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

4 participants