-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add onerror
to yew-macro listeners
#1232
Comments
@siku2 thanks for the feature request, you're the third person with this issue in the past month! I would also love to see support for all global event handlers. Agreed that the alternative you described is not ideal.
Was this confusing enough that we should address this and try to make the error message more dev friendly? |
@jstarry apologies for the duplicate issue. I was unable to find the other two issues using a simple keyword search. The error reads as follows:
Ideally there should be a note indicating that I'm passing a |
@jstarry I would love to work on this but I feel like there are few things that need to be discussed first. There are a lot of events which are specific to a particular tag. The biggest offender here are the media events. Even though some of these events are only applicable to a specific tag and some don't even bubble they can still be applied to any tag according to the spec (At least I think). There are also a lot of experimental and deprecated event handlers. One of the deprecated ones, |
Excellent! We'd love to have your help!
Yew can distinguish between various tags during the macro expansion phase if using the
This is a tough part of web development 🤕
Since
I mostly agree but I think there is good reason to have at least a little discretion. For instance, with If there's ever ambiguity, we can err on the side of adding support. |
Thanks for taking the time to respond, @jstarry. Here's an idea how to decide on which handlers to support: Here are a few examples:
What do you think about this? Regarding my second problem; whether or not to allow all event handlers on all tags.
And the spec does indeed say "[...] must be supported by all HTML elements, as both event handler content attributes and event handler IDL attributes". <span onplay="() => console.log('Hello World!')">
Definitely not a video
</span> I don't think it's necessary to spend an absurd amount of time researching which event handlers can be applied to which tags if it actually goes against the spec. While reading through the spec I did however find out that there are two other groups of event handlers:
Since it's impossible to construct a |
Sounds great to me
Got it, I agree with this.
Agreed, that they can be included with the other event handlers 👍 |
Is your feature request related to a problem? Please describe.
I was implementing an image component which falls back to a different image when it encounters an error while loading the primary one. I wanted to do this using the
onerror
event handler but it turns out that Yew doesn't support it.The event is not listed in
LISTENER_SET
which makes for an interesting error message as Yew treats it like a normal attribute.Describe the solution you'd like
I would love to see support for all global event handlers so that it's possible to use the
onerror
event handler.Describe alternatives you've considered
I tried to manually construct the img
VTag
but that turned out to be quite annoying because there's noWrapper
implementing theListener
trait generated for it.Instead I decided to use a
NodeRef
and manually callset_onerror
on it. This is really verbose though so I think it's less than ideal.The text was updated successfully, but these errors were encountered: