diff --git a/examples/keyed_list/Cargo.toml b/examples/keyed_list/Cargo.toml index 81aff6afa82..401b4755bf8 100644 --- a/examples/keyed_list/Cargo.toml +++ b/examples/keyed_list/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "MIT OR Apache-2.0" [dependencies] -fake = "2.2" +fake = "=2.4.1" getrandom = { version = "0.2", features = ["js"] } instant = { version = "0.1", features = ["wasm-bindgen"] } log = "0.4" @@ -17,6 +17,6 @@ yew = { path = "../../packages/yew" } [dependencies.web-sys] version = "0.3" features = [ - "HtmlElement", - "HtmlInputElement", + "HtmlElement", + "HtmlInputElement", ] diff --git a/examples/router/src/pages/post.rs b/examples/router/src/pages/post.rs index 61fd726d862..2ee0fb82b27 100644 --- a/examples/router/src/pages/post.rs +++ b/examples/router/src/pages/post.rs @@ -1,6 +1,5 @@ use crate::{content, generator::Generated, Route}; use content::PostPart; -use std::borrow::Cow; use yew::prelude::*; use yew_router::prelude::*; @@ -39,7 +38,7 @@ impl Component for Post { html! { <>
- +

@@ -70,7 +69,7 @@ impl Post {

- +

@@ -90,7 +89,7 @@ impl Post { fn render_section_hero(&self, section: &content::Section) -> Html { html! {
- +

{ §ion.title }

diff --git a/packages/yew-macro/src/html_tree/html_element.rs b/packages/yew-macro/src/html_tree/html_element.rs index 043d383b915..791b5b7408a 100644 --- a/packages/yew-macro/src/html_tree/html_element.rs +++ b/packages/yew-macro/src/html_tree/html_element.rs @@ -168,7 +168,7 @@ impl ToTokens for HtmlElement { expr => Value::Dynamic(quote_spanned! {expr.span()=> if #expr { ::std::option::Option::Some( - ::std::borrow::Cow::<'static, ::std::primitive::str>::Borrowed(#key) + ::yew::virtual_dom::AttrValue::Static(#key) ) } else { ::std::option::Option::None diff --git a/packages/yew-macro/src/stringify.rs b/packages/yew-macro/src/stringify.rs index f6d3fad8f66..82d60389dcf 100644 --- a/packages/yew-macro/src/stringify.rs +++ b/packages/yew-macro/src/stringify.rs @@ -6,17 +6,17 @@ use syn::{Expr, Lit, LitStr}; /// Stringify a value at runtime. fn stringify_at_runtime(src: impl ToTokens) -> TokenStream { quote_spanned! {src.span()=> - ::std::convert::Into::<::std::borrow::Cow::<'static, ::std::primitive::str>>::into(#src) + ::std::convert::Into::<::yew::virtual_dom::AttrValue>::into(#src) } } -/// Create `Cow<'static, str>` construction calls. +/// Create `AttrValue` construction calls. /// /// This is deliberately not implemented for strings to preserve spans. pub trait Stringify { /// Try to turn the value into a string literal. fn try_into_lit(&self) -> Option; - /// Create `Cow<'static, str>` however possible. + /// Create `AttrValue` however possible. fn stringify(&self) -> TokenStream; /// Optimize literals to `&'static str`, otherwise keep the value as is. @@ -71,7 +71,7 @@ impl Stringify for LitStr { fn stringify(&self) -> TokenStream { quote_spanned! {self.span()=> - ::std::borrow::Cow::<'static, ::std::primitive::str>::Borrowed(#self) + ::yew::virtual_dom::AttrValue::Static(#self) } } } diff --git a/packages/yew-macro/tests/html_macro/component-fail.stderr b/packages/yew-macro/tests/html_macro/component-fail.stderr index f52324423a9..ec0fe6427e8 100644 --- a/packages/yew-macro/tests/html_macro/component-fail.stderr +++ b/packages/yew-macro/tests/html_macro/component-fail.stderr @@ -342,8 +342,8 @@ error[E0277]: the trait bound `{integer}: IntoPropValue` is not satisfie | ^ the trait `IntoPropValue` is not implemented for `{integer}` | = help: the following implementations were found: - <&'static str as IntoPropValue>> - <&'static str as IntoPropValue>>> + <&'static str as IntoPropValue> + <&'static str as IntoPropValue>> <&'static str as IntoPropValue>> <&'static str as IntoPropValue> and 11 others @@ -355,8 +355,8 @@ error[E0277]: the trait bound `{integer}: IntoPropValue` is not satisfie | ^ the trait `IntoPropValue` is not implemented for `{integer}` | = help: the following implementations were found: - <&'static str as IntoPropValue>> - <&'static str as IntoPropValue>>> + <&'static str as IntoPropValue> + <&'static str as IntoPropValue>> <&'static str as IntoPropValue>> <&'static str as IntoPropValue> and 11 others diff --git a/packages/yew-macro/tests/html_macro/element-fail.stderr b/packages/yew-macro/tests/html_macro/element-fail.stderr index a69e3e4958e..7ee8ea4e9fc 100644 --- a/packages/yew-macro/tests/html_macro/element-fail.stderr +++ b/packages/yew-macro/tests/html_macro/element-fail.stderr @@ -1,209 +1,209 @@ error: this opening tag has no corresponding closing tag - --> $DIR/tests/html_macro/element-fail.rs:7:13 + --> tests/html_macro/element-fail.rs:7:13 | 7 | html! {
}; | ^^^^^ error: this opening tag has no corresponding closing tag - --> $DIR/tests/html_macro/element-fail.rs:8:18 + --> tests/html_macro/element-fail.rs:8:18 | 8 | html! {
}; | ^^^^^ error: this opening tag has no corresponding closing tag - --> $DIR/tests/html_macro/element-fail.rs:9:13 + --> tests/html_macro/element-fail.rs:9:13 | 9 | html! {
}; | ^^^^^ error: this closing tag has no corresponding opening tag - --> $DIR/tests/html_macro/element-fail.rs:12:13 + --> tests/html_macro/element-fail.rs:12:13 | 12 | html! {
}; | ^^^^^^ error: this closing tag has no corresponding opening tag - --> $DIR/tests/html_macro/element-fail.rs:13:18 + --> tests/html_macro/element-fail.rs:13:18 | 13 | html! {
}; | ^^^^^^^ error: only one root html element is allowed (hint: you can wrap multiple html elements in a fragment `<>`) - --> $DIR/tests/html_macro/element-fail.rs:14:20 + --> tests/html_macro/element-fail.rs:14:20 | 14 | html! { }; | ^^^^^^ error: this closing tag has no corresponding opening tag - --> $DIR/tests/html_macro/element-fail.rs:17:18 + --> tests/html_macro/element-fail.rs:17:18 | 17 | html! {
}; | ^^^^^^^ error: this closing tag has no corresponding opening tag - --> $DIR/tests/html_macro/element-fail.rs:18:20 + --> tests/html_macro/element-fail.rs:18:20 | 18 | html! { }; | ^^^^^^^^ error: only one root html element is allowed (hint: you can wrap multiple html elements in a fragment `<>`) - --> $DIR/tests/html_macro/element-fail.rs:21:24 + --> tests/html_macro/element-fail.rs:21:24 | 21 | html! {
}; | ^^^^^^^^^^^ error: expected a valid html element - --> $DIR/tests/html_macro/element-fail.rs:23:18 + --> tests/html_macro/element-fail.rs:23:18 | 23 | html! {
Invalid
}; | ^^^^^^^ error: `attr` can only be specified once but is given here again - --> $DIR/tests/html_macro/element-fail.rs:26:27 + --> tests/html_macro/element-fail.rs:26:27 | 26 | html! { }; | ^^^^ error: `value` can only be specified once but is given here again - --> $DIR/tests/html_macro/element-fail.rs:27:32 + --> tests/html_macro/element-fail.rs:27:32 | 27 | html! { }; | ^^^^^ error: `kind` can only be specified once but is given here again - --> $DIR/tests/html_macro/element-fail.rs:28:36 + --> tests/html_macro/element-fail.rs:28:36 | 28 | html! { }; | ^^^^ error: `checked` can only be specified once but is given here again - --> $DIR/tests/html_macro/element-fail.rs:29:33 + --> tests/html_macro/element-fail.rs:29:33 | 29 | html! { }; | ^^^^^^^ error: `disabled` can only be specified once but is given here again - --> $DIR/tests/html_macro/element-fail.rs:30:34 + --> tests/html_macro/element-fail.rs:30:34 | 30 | html! { }; | ^^^^^^^^ error: `selected` can only be specified once but is given here again - --> $DIR/tests/html_macro/element-fail.rs:31:35 + --> tests/html_macro/element-fail.rs:31:35 | 31 | html! {