Add focusin and focusout event support (#1945)

* Adds focusin and focusout event support

* Update element-fail.stderr file
This commit is contained in:
mc1098 2021-07-09 18:21:44 +01:00 committed by GitHub
parent 44d920b813
commit 0f92d4878e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 20 deletions

View File

@ -121,6 +121,10 @@ lazy_static! {
"onended",
"onerror",
"onfocus",
// onfocusin + onfocusout not in standard but added due to browser support
// see issue 1896: https://github.com/yewstack/yew/issues/1896
"onfocusin",
"onfocusout",
"onformdata",
"oninput",
"oninvalid",

View File

@ -198,9 +198,9 @@ error[E0277]: the trait bound `(): IntoPropValue<Option<Cow<'static, str>>>` is
45 | html! { <a href=() /> };
| ^^ the trait `IntoPropValue<Option<Cow<'static, str>>>` is not implemented for `()`
|
::: $WORKSPACE/packages/yew/src/virtual_dom/mod.rs:61:47
::: $WORKSPACE/packages/yew/src/virtual_dom/mod.rs
|
61 | pub fn new(key: &'static str, value: impl IntoPropValue<Option<AttrValue>>) -> Self {
| pub fn new(key: &'static str, value: impl IntoPropValue<Option<AttrValue>>) -> Self {
| -------------------------------- required by this bound in `PositionalAttr::new`
error[E0277]: the trait bound `NotToString: IntoPropValue<Option<Cow<'static, str>>>` is not satisfied
@ -209,9 +209,9 @@ error[E0277]: the trait bound `NotToString: IntoPropValue<Option<Cow<'static, st
46 | html! { <input string=NotToString /> };
| ^^^^^^^^^^^ the trait `IntoPropValue<Option<Cow<'static, str>>>` is not implemented for `NotToString`
|
::: $WORKSPACE/packages/yew/src/virtual_dom/mod.rs:61:47
::: $WORKSPACE/packages/yew/src/virtual_dom/mod.rs
|
61 | pub fn new(key: &'static str, value: impl IntoPropValue<Option<AttrValue>>) -> Self {
| pub fn new(key: &'static str, value: impl IntoPropValue<Option<AttrValue>>) -> Self {
| -------------------------------- required by this bound in `PositionalAttr::new`
error[E0277]: the trait bound `Option<NotToString>: IntoPropValue<Option<Cow<'static, str>>>` is not satisfied
@ -220,9 +220,9 @@ error[E0277]: the trait bound `Option<NotToString>: IntoPropValue<Option<Cow<'st
47 | html! { <a media=Some(NotToString) /> };
| ^^^^^^^^^^^^^^^^^ the trait `IntoPropValue<Option<Cow<'static, str>>>` is not implemented for `Option<NotToString>`
|
::: $WORKSPACE/packages/yew/src/virtual_dom/mod.rs:61:47
::: $WORKSPACE/packages/yew/src/virtual_dom/mod.rs
|
61 | pub fn new(key: &'static str, value: impl IntoPropValue<Option<AttrValue>>) -> Self {
| pub fn new(key: &'static str, value: impl IntoPropValue<Option<AttrValue>>) -> Self {
| -------------------------------- required by this bound in `PositionalAttr::new`
|
= help: the following implementations were found:
@ -236,9 +236,9 @@ error[E0277]: the trait bound `Option<{integer}>: IntoPropValue<Option<Cow<'stat
48 | html! { <a href=Some(5) /> };
| ^^^^^^^ the trait `IntoPropValue<Option<Cow<'static, str>>>` is not implemented for `Option<{integer}>`
|
::: $WORKSPACE/packages/yew/src/virtual_dom/mod.rs:61:47
::: $WORKSPACE/packages/yew/src/virtual_dom/mod.rs
|
61 | pub fn new(key: &'static str, value: impl IntoPropValue<Option<AttrValue>>) -> Self {
| pub fn new(key: &'static str, value: impl IntoPropValue<Option<AttrValue>>) -> Self {
| -------------------------------- required by this bound in `PositionalAttr::new`
|
= help: the following implementations were found:
@ -252,15 +252,15 @@ error[E0277]: the trait bound `{integer}: IntoPropValue<Option<yew::Callback<Mou
51 | html! { <input onclick=1 /> };
| ^ the trait `IntoPropValue<Option<yew::Callback<MouseEvent>>>` is not implemented for `{integer}`
|
::: $WORKSPACE/packages/yew/src/html/listener/events.rs:2:1
::: $WORKSPACE/packages/yew/src/html/listener/events.rs
|
2 | / impl_action! {
| / impl_action! {
3 | | onabort(name: "abort", event: Event) -> web_sys::Event => |_, event| { event }
4 | | onauxclick(name: "auxclick", event: MouseEvent) -> web_sys::MouseEvent => |_, event| { event }
5 | | onblur(name: "blur", event: FocusEvent) -> web_sys::FocusEvent => |_, event| { event }
... |
99 | | ontransitionstart(name: "transitionstart", event: TransitionEvent) -> web_sys::TransitionEvent => |_, event| { event }
100 | | }
101 | | ontransitionstart(name: "transitionstart", event: TransitionEvent) -> web_sys::TransitionEvent => |_, event| { event }
102 | | }
| |_- required by this bound in `yew::html::onclick::Wrapper::__macro_new`
|
= help: the following implementations were found:
@ -276,15 +276,15 @@ error[E0277]: the trait bound `yew::Callback<String>: IntoPropValue<Option<yew::
52 | html! { <input onclick=Callback::from(|a: String| ()) /> };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoPropValue<Option<yew::Callback<MouseEvent>>>` is not implemented for `yew::Callback<String>`
|
::: $WORKSPACE/packages/yew/src/html/listener/events.rs:2:1
::: $WORKSPACE/packages/yew/src/html/listener/events.rs
|
2 | / impl_action! {
| / impl_action! {
3 | | onabort(name: "abort", event: Event) -> web_sys::Event => |_, event| { event }
4 | | onauxclick(name: "auxclick", event: MouseEvent) -> web_sys::MouseEvent => |_, event| { event }
5 | | onblur(name: "blur", event: FocusEvent) -> web_sys::FocusEvent => |_, event| { event }
... |
99 | | ontransitionstart(name: "transitionstart", event: TransitionEvent) -> web_sys::TransitionEvent => |_, event| { event }
100 | | }
101 | | ontransitionstart(name: "transitionstart", event: TransitionEvent) -> web_sys::TransitionEvent => |_, event| { event }
102 | | }
| |_- required by this bound in `yew::html::onclick::Wrapper::__macro_new`
error[E0277]: the trait bound `Option<{integer}>: IntoPropValue<Option<yew::Callback<FocusEvent>>>` is not satisfied
@ -293,15 +293,15 @@ error[E0277]: the trait bound `Option<{integer}>: IntoPropValue<Option<yew::Call
53 | html! { <input onfocus=Some(5) /> };
| ^^^^^^^ the trait `IntoPropValue<Option<yew::Callback<FocusEvent>>>` is not implemented for `Option<{integer}>`
|
::: $WORKSPACE/packages/yew/src/html/listener/events.rs:2:1
::: $WORKSPACE/packages/yew/src/html/listener/events.rs
|
2 | / impl_action! {
| / impl_action! {
3 | | onabort(name: "abort", event: Event) -> web_sys::Event => |_, event| { event }
4 | | onauxclick(name: "auxclick", event: MouseEvent) -> web_sys::MouseEvent => |_, event| { event }
5 | | onblur(name: "blur", event: FocusEvent) -> web_sys::FocusEvent => |_, event| { event }
... |
99 | | ontransitionstart(name: "transitionstart", event: TransitionEvent) -> web_sys::TransitionEvent => |_, event| { event }
100 | | }
101 | | ontransitionstart(name: "transitionstart", event: TransitionEvent) -> web_sys::TransitionEvent => |_, event| { event }
102 | | }
| |_- required by this bound in `yew::html::onfocus::Wrapper::__macro_new`
|
= help: the following implementations were found:

View File

@ -25,6 +25,8 @@ impl_action! {
onended(name: "ended", event: Event) -> web_sys::Event => |_, event| { event }
onerror(name: "error", event: Event) -> web_sys::Event => |_, event| { event }
onfocus(name: "focus", event: FocusEvent) -> web_sys::FocusEvent => |_, event| { event }
onfocusin(name: "focusin", event: FocusEvent) -> web_sys::FocusEvent => |_, event| { event }
onfocusout(name: "focusout", event: FocusEvent) -> web_sys::FocusEvent => |_, event| { event }
// web_sys doesn't have a struct for `FormDataEvent`
onformdata(name: "formdata", event: Event) -> web_sys::Event => |_, event| { event }
oninput(name: "input", event: InputEvent) -> InputData => |this: &Element, event| { oninput_handler(this, event) }

View File

@ -243,6 +243,8 @@ end up using a version which conflicts with the version that Yew specifies.
| `onended` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) |
| `onerror` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) |
| `onfocus` | [FocusEvent](https://docs.rs/web-sys/latest/web_sys/struct.FocusEvent.html) |
| `onfocusin` | [FocusEvent](https://docs.rs/web-sys/latest/web_sys/struct.FocusEvent.html) |
| `onfocusout` | [FocusEvent](https://docs.rs/web-sys/latest/web_sys/struct.FocusEvent.html) |
| `onformdata` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) |
| `oninput` | [InputData](https://docs.rs/yew/latest/yew/events/struct.InputData.html) |
| `oninvalid` | [Event](https://docs.rs/web-sys/latest/web_sys/struct.Event.html) |