-
-
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
Allow all global event handlers to be used as listeners #1244
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely done! Thank you
I'm not very experienced with stdweb so I'm unaware if there's another way to support them.
Since stdweb
is not actively maintained, there isn't much we can do at this point. I'm not very interested in forking it since web-sys
is a great alternative.
Which, sadly, isn't very descriptive. Perhaps there is a way to improve this?
We could add a std_web
(Yew naming convention) cargo feature to the yew-macro
crate and enable it in yew-stdweb/Cargo.toml
. Then, use that macro to add a stdweb
specific check for the unsupported listeners and return a nice syn::Error::new_spanned(..)
error.
I also wasn't sure how you're updating yew-stdweb so I didn't touch it.
It's just an alias to yew with different default cargo features
It seems like error: the listener `onplay` is only available when using web-sys
|
| <video onplay=self.link.callback(|_| Msg::PlayStarted)>{ ... }</video>
| ^^^^^^ What do you think?
Hah, I should've noticed it was just a symlink to Yew's |
Thanks! There are still quite a few Yew devs that are still using
Beautiful 👍 |
Fixes #1232
Please refer to the issue for more information about the problem.
Added event handlers
oncopy
,oncut
, andonpaste
which can only be applied to HTML elementsRemoved existing event handlers
onmousewheel
- deprecated, replaced byonwheel
ontouchenter
- no longer part of the working draft (see here)A note about
stdweb
stdweb
doesn't support a lot of the event handlers because it doesn't have structs representing their event data.I'm not very experienced with
stdweb
so I'm unaware if there's another way to support them.My brief research only uncovered this from another project with the same problem and it doesn't present a solution.
Currently, if a user tries to use an event which isn't implemented the error message looks something like this:
Which, sadly, isn't very descriptive. Perhaps there is a way to improve this?
Using two separate
LISTENER_SET
declarations wouldn't help in my opinion because the error message for passing a callback to a non-listener attribute isn't very clear either (example).I also wasn't sure how you're updating
yew-stdweb
so I didn't touch it.