(
110 | | ----------------------- required by a bound in this function
111 | | _f: &impl Component,
112 | | ^^^^^^^^^^^^ required by this bound in `component_props_builder`
113 |
114 | error[E0599]: the method `children` exists for struct `ShowPropsBuilder`, but its trait bounds were not satisfied
115 | --> tests/ui/errors/com_builder_spans.rs:26:13
116 | |
117 | 24 | _ = mview! {
118 | | _________-
119 | 25 | | Show when={true} {
120 | 26 | | "hi"
121 | | | -^^^^ method cannot be called on `ShowPropsBuilder` due to unsatisfied trait bounds
122 | | |____________|
123 | |
124 | |
125 | = note: the following trait bounds were not satisfied:
126 | `bool: std::ops::Fn<()>`
127 | `bool: FnOnce<()>`
128 | which is required by `>::Output = bool`
129 |
130 | error[E0308]: mismatched types
131 | --> tests/ui/errors/com_builder_spans.rs:37:21
132 | |
133 | 37 | Thing label=[false];
134 | | ----- ^^^^^^^ expected `&str`, found closure
135 | | |
136 | | arguments to this method are incorrect
137 | |
138 | = note: expected reference `&'static str`
139 | found closure `{closure@$DIR/tests/ui/errors/com_builder_spans.rs:37:21: 37:28}`
140 | note: method defined here
141 | --> tests/ui/errors/com_builder_spans.rs:33:14
142 | |
143 | 33 | fn Thing(label: &'static str) -> impl IntoView { label }
144 | | ^^^^^--------------
145 |
146 | error[E0308]: mismatched types
147 | --> tests/ui/errors/com_builder_spans.rs:48:15
148 | |
149 | 48 | Thing |s| { "hello" }
150 | | ^^^ expected `Box Fragment>`, found closure
151 | |
152 | = note: expected struct `Box<(dyn FnOnce() -> Fragment + 'static)>`
153 | found closure `{closure@$DIR/tests/ui/errors/com_builder_spans.rs:48:15: 48:18}`
154 |
155 | error[E0283]: type annotations needed
156 | --> tests/ui/errors/com_builder_spans.rs:57:9
157 | |
158 | 57 | Await future=[async { 3 }] { "no args" }
159 | | ^^^^^ cannot infer type of the type parameter `V` declared on the function `Await`
160 | |
161 | = note: cannot satisfy `_: leptos::IntoView`
162 | = help: the following types implement trait `leptos::IntoView`:
163 | &'static str
164 | &Fragment
165 | &leptos::View
166 | &std::string::String
167 | ()
168 | (A, B)
169 | (A, B, C)
170 | (A, B, C, D)
171 | and $N others
172 | note: required by a bound in `leptos::Await`
173 | --> $CARGO/leptos-0.6.12/src/await_.rs
174 | |
175 | | pub fn Await(
176 | | ----- required by a bound in this function
177 | ...
178 | | V: IntoView,
179 | | ^^^^^^^^ required by this bound in `Await`
180 | help: consider specifying the generic arguments
181 | |
182 | 57 | Await:: future=[async { 3 }] { "no args" }
183 | | ++++++++++++++++++++
184 |
185 | error[E0283]: type annotations needed
186 | --> tests/ui/errors/com_builder_spans.rs:57:9
187 | |
188 | 57 | Await future=[async { 3 }] { "no args" }
189 | | ^^^^^ cannot infer type of the type parameter `VF` declared on the function `Await`
190 | |
191 | = note: multiple `impl`s satisfying `_: ToChildren<{closure@$DIR/tests/ui/errors/com_builder_spans.rs:57:38: 57:47}>` found in the `leptos` crate:
192 | - impl ToChildren for Box<(dyn FnMut() -> Fragment + 'static)>
193 | where >::Output == Fragment, F: FnMut(), F: 'static;
194 | - impl ToChildren for Box<(dyn FnOnce() -> Fragment + 'static)>
195 | where >::Output == Fragment, F: FnOnce(), F: 'static;
196 | - impl ToChildren for Box<(dyn std::ops::Fn() -> Fragment + 'static)>
197 | where >::Output == Fragment, F: Fn(), F: 'static;
198 | - impl ToChildren for Rc<(dyn std::ops::Fn() -> Fragment + 'static)>
199 | where >::Output == Fragment, F: Fn(), F: 'static;
200 | help: consider specifying the generic arguments
201 | |
202 | 57 | Await:: future=[async { 3 }] { "no args" }
203 | | ++++++++++++++++++++
204 |
--------------------------------------------------------------------------------
/tests/ui/errors/com_dyn_classes.rs:
--------------------------------------------------------------------------------
1 | use leptos::*;
2 | use leptos_mview::mview;
3 |
4 | #[component]
5 | fn AComponent(
6 | #[prop(into, default="".into())] class: TextProp,
7 | #[prop(optional)] id: &'static str,
8 | ) -> impl IntoView {
9 | mview! {
10 | div class=f["my-class {}", class.get()] {id};
11 | }
12 | }
13 |
14 | fn missing_closure() {
15 | _ = mview! {
16 | AComponent class:red=true;
17 | };
18 | }
19 |
20 | fn incorrect_type() {
21 | _ = mview! {
22 | AComponent class:red=["not this"];
23 | };
24 | }
25 |
26 | #[component]
27 | fn Nothing() -> impl IntoView {}
28 |
29 | // these spans are actually fine, there's a blank info message at `mview!` for
30 | // some reason.
31 |
32 | fn no_attribute_reactive() {
33 | _ = mview! {
34 | Nothing class:red=[true];
35 | };
36 | }
37 |
38 | fn no_attribute_static() {
39 | _ = mview! {
40 | Nothing.red;
41 | };
42 | }
43 |
44 | fn no_attribute_id() {
45 | _ = mview! {
46 | Nothing #unique;
47 | };
48 | }
49 |
50 | fn main() {}
51 |
--------------------------------------------------------------------------------
/tests/ui/errors/com_dyn_classes.stderr:
--------------------------------------------------------------------------------
1 | error[E0618]: expected function, found `bool`
2 | --> tests/ui/errors/com_dyn_classes.rs:16:30
3 | |
4 | 16 | AComponent class:red=true;
5 | | ^^^^ call expression requires function
6 |
7 | error[E0308]: mismatched types
8 | --> tests/ui/errors/com_dyn_classes.rs:22:30
9 | |
10 | 22 | AComponent class:red=["not this"];
11 | | ^^^^^^^^^^^^
12 | | |
13 | | expected `bool`, found `&str`
14 | | arguments to this function are incorrect
15 | |
16 | note: method defined here
17 | --> $RUST/core/src/bool.rs
18 | |
19 | | pub fn then_some(self, t: T) -> Option {
20 | | ^^^^^^^^^
21 |
22 | error[E0599]: no method named `class` found for struct `EmptyPropsBuilder` in the current scope
23 | --> tests/ui/errors/com_dyn_classes.rs:34:17
24 | |
25 | 33 | _ = mview! {
26 | | _________-
27 | 34 | | Nothing class:red=[true];
28 | | | -^^^^^ method not found in `EmptyPropsBuilder`
29 | | |________________|
30 | |
31 |
32 | error[E0599]: no method named `class` found for struct `EmptyPropsBuilder` in the current scope
33 | --> tests/ui/errors/com_dyn_classes.rs:40:16
34 | |
35 | 39 | _ = mview! {
36 | | _________-
37 | 40 | | Nothing.red;
38 | | | -^ method not found in `EmptyPropsBuilder`
39 | | |_______________|
40 | |
41 |
42 | error[E0599]: no method named `id` found for struct `EmptyPropsBuilder` in the current scope
43 | --> tests/ui/errors/com_dyn_classes.rs:46:17
44 | |
45 | 45 | _ = mview! {
46 | | _________-
47 | 46 | | Nothing #unique;
48 | | | -^ method not found in `EmptyPropsBuilder`
49 | | |________________|
50 | |
51 |
--------------------------------------------------------------------------------
/tests/ui/errors/invalid_child.rs:
--------------------------------------------------------------------------------
1 | use leptos_mview::mview;
2 |
3 | fn main() {
4 | let a = "a";
5 | mview! {
6 | (a)
7 | };
8 | }
9 |
10 | // checking that it doesn't suggest adding `|_| {value}`
11 | fn not_impl_intoview() {
12 | // &&str doesn't impl IntoView, &str does
13 | // should be `{*value}`
14 | let value: &&str = &"hi";
15 | _ = mview! {
16 | span (
17 | {value}
18 | )
19 | };
20 |
21 | // forgot to call `.collect_view()`
22 | let values: Vec<&'static str> = vec!["hi", "bye", "howdy", "hello", "hey"];
23 | _ = mview! {
24 | ul {
25 | {values
26 | .into_iter()
27 | .map(|val: &str| {
28 | mview! { li({val}) }
29 | })
30 | }
31 | }
32 | }
33 | }
34 |
35 | fn extra_semicolons() {
36 | _ = mview! {
37 | div { "hi there" };
38 | span;
39 | };
40 | }
41 |
42 | #[expect(dependency_on_unit_never_type_fallback, reason="probably fixed in leptos 0.7")]
43 | fn unreachable_code() {
44 | _ = mview! {
45 | div {
46 | {todo!()}
47 | }
48 | };
49 | }
50 |
--------------------------------------------------------------------------------
/tests/ui/errors/invalid_child.stderr:
--------------------------------------------------------------------------------
1 | error: invalid child: expected literal, block, bracket or element
2 | --> tests/ui/errors/invalid_child.rs:6:9
3 | |
4 | 6 | (a)
5 | | ^
6 |
7 | error: extra semi-colon found
8 | --> tests/ui/errors/invalid_child.rs:37:27
9 | |
10 | 37 | div { "hi there" };
11 | | ^
12 | |
13 | = help: remove this semi-colon
14 |
15 | error[E0277]: the trait bound `&&str: IntoView` is not satisfied
16 | --> tests/ui/errors/invalid_child.rs:17:14
17 | |
18 | 17 | {value}
19 | | -^^^^^-
20 | | ||
21 | | |the trait `Fn()` is not implemented for `str`, which is required by `&&str: IntoView`
22 | | required by a bound introduced by this call
23 | |
24 | = help: the trait `IntoView` is implemented for `&'static str`
25 | = note: required for `&str` to implement `FnOnce()`
26 | = note: required for `&&str` to implement `IntoView`
27 | note: required by a bound in `leptos::HtmlElement::::child`
28 | --> $CARGO/leptos_dom-0.6.12/src/html.rs
29 | |
30 | | pub fn child(self, child: impl IntoView) -> Self {
31 | | ^^^^^^^^ required by this bound in `HtmlElement::::child`
32 |
33 | error[E0277]: the trait bound `std::iter::Map, {closure@$DIR/tests/ui/errors/invalid_child.rs:27:22: 27:33}>: IntoView` is not satisfied
34 | --> tests/ui/errors/invalid_child.rs:25:14
35 | |
36 | 25 | {values
37 | | ______________-^
38 | | | ______________|
39 | 26 | || .into_iter()
40 | 27 | || .map(|val: &str| {
41 | 28 | || mview! { li({val}) }
42 | 29 | || })
43 | | ||__________________^ the trait `Fn()` is not implemented for `std::iter::Map, {closure@$DIR/tests/ui/errors/invalid_child.rs:27:22: 27:33}>`, which is required by `std::iter::Map, {closure@$DIR/tests/ui/errors/invalid_child.rs:27:22: 27:33}>: IntoView`
44 | 30 | | }
45 | | |______________- required by a bound introduced by this call
46 | |
47 | = help: the following other types implement trait `IntoView`:
48 | &'static str
49 | &Fragment
50 | &leptos::View
51 | &std::string::String
52 | ()
53 | (A, B)
54 | (A, B, C)
55 | (A, B, C, D)
56 | and $N others
57 | = note: required for `std::iter::Map, {closure@$DIR/tests/ui/errors/invalid_child.rs:27:22: 27:33}>` to implement `IntoView`
58 | note: required by a bound in `leptos::HtmlElement::::child`
59 | --> $CARGO/leptos_dom-0.6.12/src/html.rs
60 | |
61 | | pub fn child(self, child: impl IntoView) -> Self {
62 | | ^^^^^^^^ required by this bound in `HtmlElement::::child`
63 |
64 | warning: unreachable call
65 | --> tests/ui/errors/invalid_child.rs:46:13
66 | |
67 | 46 | {todo!()}
68 | | ^-------^
69 | | ||
70 | | |any code following this expression is unreachable
71 | | unreachable call
72 | |
73 | = note: `#[warn(unreachable_code)]` on by default
74 |
75 | warning: unused variable: `a`
76 | --> tests/ui/errors/invalid_child.rs:4:9
77 | |
78 | 4 | let a = "a";
79 | | ^ help: if this is intentional, prefix it with an underscore: `_a`
80 | |
81 | = note: `#[warn(unused_variables)]` on by default
82 |
--------------------------------------------------------------------------------
/tests/ui/errors/invalid_directive.rs:
--------------------------------------------------------------------------------
1 | use leptos::*;
2 | use leptos_mview::mview;
3 |
4 | fn not_directive() {
5 | mview! {
6 | div something:yes="b" {}
7 | };
8 | }
9 |
10 | fn not_class_name() {
11 | mview! {
12 | div class:("abcd") = true {}
13 | };
14 | }
15 |
16 | fn not_style_name() {
17 | mview! {
18 | div style:[1, 2]="black" {}
19 | };
20 | }
21 |
22 | fn not_event_name() {
23 | mview! {
24 | button on:clicky-click={move |_| ()};
25 | };
26 | }
27 |
28 | fn invalid_modifier() {
29 | mview! {
30 | button on:click:delegated={|_| ()};
31 | };
32 | }
33 |
34 | #[component]
35 | fn Com(#[prop(optional, into)] class: TextProp) -> impl IntoView {
36 | let _ = class;
37 | }
38 |
39 | fn invalid_parts() {
40 | _ = mview! {
41 | div class:this:undelegated=true;
42 | };
43 | _ = mview! {
44 | div style:position:undelegated="absolute";
45 | };
46 | _ = mview! {
47 | input prop:value:something="input something";
48 | };
49 | _ = mview! {
50 | button use:directive:another;
51 | };
52 | _ = mview! {
53 | button attr:type="submit";
54 | };
55 |
56 | let to_clone = String::new();
57 | _ = mview! {
58 | Com clone:to_clone:undelegated;
59 | };
60 | _ = mview! {
61 | Com clone:{to_clone};
62 | };
63 | _ = mview! {
64 | Com class:aaa:undelegated=[false];
65 | };
66 | }
67 |
68 | fn directive(_el: leptos::HtmlElement) {}
69 |
70 | fn main() {}
71 |
--------------------------------------------------------------------------------
/tests/ui/errors/invalid_directive.stderr:
--------------------------------------------------------------------------------
1 | error: unknown directive
2 | --> tests/ui/errors/invalid_directive.rs:6:13
3 | |
4 | 6 | div something:yes="b" {}
5 | | ^^^^^^^^^
6 |
7 | error: expected a kebab-cased ident
8 | --> tests/ui/errors/invalid_directive.rs:12:19
9 | |
10 | 12 | div class:("abcd") = true {}
11 | | ^
12 |
13 | error: expected a kebab-cased ident
14 | --> tests/ui/errors/invalid_directive.rs:18:19
15 | |
16 | 18 | div style:[1, 2]="black" {}
17 | | ^
18 |
19 | error: unknown modifier
20 | --> tests/ui/errors/invalid_directive.rs:30:25
21 | |
22 | 30 | button on:click:delegated={|_| ()};
23 | | ^^^^^^^^^
24 | |
25 | = help: :undelegated is the only known modifier
26 |
27 | error: unknown modifier: modifiers are only supported on `on:` directives
28 | --> tests/ui/errors/invalid_directive.rs:41:24
29 | |
30 | 41 | div class:this:undelegated=true;
31 | | ^^^^^^^^^^^
32 |
33 | error: unknown modifier: modifiers are only supported on `on:` directives
34 | --> tests/ui/errors/invalid_directive.rs:44:28
35 | |
36 | 44 | div style:position:undelegated="absolute";
37 | | ^^^^^^^^^^^
38 |
39 | error: unknown modifier: modifiers are only supported on `on:` directives
40 | --> tests/ui/errors/invalid_directive.rs:47:26
41 | |
42 | 47 | input prop:value:something="input something";
43 | | ^^^^^^^^^
44 |
45 | error: unknown modifier: modifiers are only supported on `on:` directives
46 | --> tests/ui/errors/invalid_directive.rs:50:30
47 | |
48 | 50 | button use:directive:another;
49 | | ^^^^^^^
50 |
51 | error: `attr:` is not supported on elements
52 | --> tests/ui/errors/invalid_directive.rs:53:16
53 | |
54 | 53 | button attr:type="submit";
55 | | ^^^^
56 |
57 | error: unknown modifier: modifiers are only supported on `on:` directives
58 | --> tests/ui/errors/invalid_directive.rs:58:28
59 | |
60 | 58 | Com clone:to_clone:undelegated;
61 | | ^^^^^^^^^^^
62 |
63 | error: `clone:` does not take any values
64 | --> tests/ui/errors/invalid_directive.rs:61:19
65 | |
66 | 61 | Com clone:{to_clone};
67 | | ^^^^^^^^^^
68 |
69 | error: unknown modifier: modifiers are only supported on `on:` directives
70 | --> tests/ui/errors/invalid_directive.rs:64:23
71 | |
72 | 64 | Com class:aaa:undelegated=[false];
73 | | ^^^^^^^^^^^
74 |
75 | error[E0425]: cannot find value `clicky_click` in module `leptos::ev`
76 | --> tests/ui/errors/invalid_directive.rs:24:19
77 | |
78 | 24 | button on:clicky-click={move |_| ()};
79 | | ^^^^^^^^^^^^ not found in `leptos::ev`
80 |
81 | warning: unused variable: `to_clone`
82 | --> tests/ui/errors/invalid_directive.rs:56:9
83 | |
84 | 56 | let to_clone = String::new();
85 | | ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_to_clone`
86 | |
87 | = note: `#[warn(unused_variables)]` on by default
88 |
--------------------------------------------------------------------------------
/tests/ui/errors/invalid_value.rs:
--------------------------------------------------------------------------------
1 | use leptos_mview::mview;
2 |
3 | fn unwrapped() {
4 | _ = mview! {
5 | div a=a {}
6 | };
7 | }
8 |
9 | fn no_spread() {
10 | _ = mview! {
11 | div {..};
12 | };
13 | }
14 |
15 | // ensure that it is spanned to the delims, not call site
16 | fn empty_value() {
17 | _ = mview! {
18 | a href={};
19 | a href=();
20 | a href=[];
21 | };
22 | }
23 |
24 | fn missing_value_no_remaining() {
25 | // nothing after the =, make sure that the error is on the = not call site
26 | _ = mview! {
27 | a href=
28 | };
29 | }
30 |
31 | fn main() {}
32 |
--------------------------------------------------------------------------------
/tests/ui/errors/invalid_value.stderr:
--------------------------------------------------------------------------------
1 | error: expected value after =
2 | --> tests/ui/errors/invalid_value.rs:5:15
3 | |
4 | 5 | div a=a {}
5 | | ^
6 | |
7 | = help: you may have meant to wrap this in braces
8 |
9 | error: expected value after =
10 | --> tests/ui/errors/invalid_value.rs:19:16
11 | |
12 | 19 | a href=();
13 | | ^
14 |
15 | error: extra semi-colon found
16 | --> tests/ui/errors/invalid_value.rs:19:18
17 | |
18 | 19 | a href=();
19 | | ^
20 | |
21 | = help: remove this semi-colon
22 |
23 | error: expected value after =
24 | --> tests/ui/errors/invalid_value.rs:27:15
25 | |
26 | 27 | a href=
27 | | ^
28 |
29 | error: unterminated element
30 | --> tests/ui/errors/invalid_value.rs:27:9
31 | |
32 | 27 | a href=
33 | | ^
34 | |
35 | = help: add a `;` to terminate the element with no children
36 |
37 | error[E0277]: the trait bound `MissingValueAfterEq: IntoAttribute` is not satisfied
38 | --> tests/ui/errors/invalid_value.rs:5:15
39 | |
40 | 4 | _ = mview! {
41 | | _________-
42 | 5 | | div a=a {}
43 | | | ^ the trait `Fn()` is not implemented for `MissingValueAfterEq`, which is required by `MissingValueAfterEq: IntoAttribute`
44 | 6 | | };
45 | | |_____- required by a bound introduced by this call
46 | |
47 | = help: the following other types implement trait `IntoAttribute`:
48 | &'static str
49 | &std::string::String
50 | Arguments<'_>
51 | Cow<'static, str>
52 | Nonce
53 | Oco<'static, str>
54 | Rc
55 | TextProp
56 | and $N others
57 | = note: required for `MissingValueAfterEq` to implement `IntoAttribute`
58 | note: required by a bound in `leptos::HtmlElement::::attr`
59 | --> $CARGO/leptos_dom-0.6.12/src/html.rs
60 | |
61 | | pub fn attr(
62 | | ---- required by a bound in this associated function
63 | ...
64 | | attr: impl IntoAttribute,
65 | | ^^^^^^^^^^^^^ required by this bound in `HtmlElement::::attr`
66 |
67 | error[E0061]: this method takes 1 argument but 0 arguments were supplied
68 | --> tests/ui/errors/invalid_value.rs:11:14
69 | |
70 | 11 | div {..};
71 | | ______________^^-
72 | 12 | | };
73 | | |_____- an argument is missing
74 | |
75 | note: method defined here
76 | --> $CARGO/leptos_dom-0.6.12/src/html.rs
77 | |
78 | | pub fn attrs(
79 | | ^^^^^
80 | help: provide the argument
81 | |
82 | 10 | _ = ..(/* attrs */);
83 | | ~~~~~~~~~~~~~~~
84 |
85 | error[E0277]: the trait bound `(): IntoAttribute` is not satisfied
86 | --> tests/ui/errors/invalid_value.rs:18:16
87 | |
88 | 17 | _ = mview! {
89 | | _________-
90 | 18 | | a href={};
91 | | | ^^ the trait `Fn()` is not implemented for `()`, which is required by `(): IntoAttribute`
92 | 19 | | a href=();
93 | 20 | | a href=[];
94 | 21 | | };
95 | | |_____- required by a bound introduced by this call
96 | |
97 | = help: the following other types implement trait `IntoAttribute`:
98 | &'static str
99 | &std::string::String
100 | Arguments<'_>
101 | Cow<'static, str>
102 | Nonce
103 | Oco<'static, str>
104 | Rc
105 | TextProp
106 | and $N others
107 | = note: required for `()` to implement `IntoAttribute`
108 | note: required by a bound in `leptos::HtmlElement::::attr`
109 | --> $CARGO/leptos_dom-0.6.12/src/html.rs
110 | |
111 | | pub fn attr(
112 | | ---- required by a bound in this associated function
113 | ...
114 | | attr: impl IntoAttribute,
115 | | ^^^^^^^^^^^^^ required by this bound in `HtmlElement::::attr`
116 |
117 | error[E0277]: the trait bound `MissingValueAfterEq: IntoAttribute` is not satisfied
118 | --> tests/ui/errors/invalid_value.rs:19:16
119 | |
120 | 17 | _ = mview! {
121 | | _________-
122 | 18 | | a href={};
123 | 19 | | a href=();
124 | | | ^ the trait `Fn()` is not implemented for `MissingValueAfterEq`, which is required by `MissingValueAfterEq: IntoAttribute`
125 | 20 | | a href=[];
126 | 21 | | };
127 | | |_____- required by a bound introduced by this call
128 | |
129 | = help: the following other types implement trait `IntoAttribute`:
130 | &'static str
131 | &std::string::String
132 | Arguments<'_>
133 | Cow<'static, str>
134 | Nonce
135 | Oco<'static, str>
136 | Rc
137 | TextProp
138 | and $N others
139 | = note: required for `MissingValueAfterEq` to implement `IntoAttribute`
140 | note: required by a bound in `leptos::HtmlElement::::attr`
141 | --> $CARGO/leptos_dom-0.6.12/src/html.rs
142 | |
143 | | pub fn attr(
144 | | ---- required by a bound in this associated function
145 | ...
146 | | attr: impl IntoAttribute,
147 | | ^^^^^^^^^^^^^ required by this bound in `HtmlElement::::attr`
148 |
149 | error[E0277]: expected a `Fn()` closure, found `()`
150 | --> tests/ui/errors/invalid_value.rs:20:16
151 | |
152 | 17 | _ = mview! {
153 | | _________-
154 | 18 | | a href={};
155 | 19 | | a href=();
156 | 20 | | a href=[];
157 | | | ^^ expected an `Fn()` closure, found `()`
158 | 21 | | };
159 | | |_____- required by a bound introduced by this call
160 | |
161 | = help: the trait `Fn()` is not implemented for `()`, which is required by `{closure@$DIR/tests/ui/errors/invalid_value.rs:20:16: 20:18}: IntoAttribute`
162 | = note: wrap the `()` in a closure with no arguments: `|| { /* code */ }`
163 | = help: the following other types implement trait `IntoAttribute`:
164 | &'static str
165 | &std::string::String
166 | Arguments<'_>
167 | Cow<'static, str>
168 | Nonce
169 | Oco<'static, str>
170 | Rc
171 | TextProp
172 | and $N others
173 | = note: required for `()` to implement `IntoAttribute`
174 | = note: 1 redundant requirement hidden
175 | = note: required for `{closure@$DIR/tests/ui/errors/invalid_value.rs:20:16: 20:18}` to implement `IntoAttribute`
176 | note: required by a bound in `leptos::HtmlElement::::attr`
177 | --> $CARGO/leptos_dom-0.6.12/src/html.rs
178 | |
179 | | pub fn attr(
180 | | ---- required by a bound in this associated function
181 | ...
182 | | attr: impl IntoAttribute,
183 | | ^^^^^^^^^^^^^ required by this bound in `HtmlElement::::attr`
184 |
185 | error[E0277]: the trait bound `MissingValueAfterEq: IntoAttribute` is not satisfied
186 | --> tests/ui/errors/invalid_value.rs:27:15
187 | |
188 | 26 | _ = mview! {
189 | | _________-
190 | 27 | | a href=
191 | | | ^ the trait `Fn()` is not implemented for `MissingValueAfterEq`, which is required by `MissingValueAfterEq: IntoAttribute`
192 | 28 | | };
193 | | |_____- required by a bound introduced by this call
194 | |
195 | = help: the following other types implement trait `IntoAttribute`:
196 | &'static str
197 | &std::string::String
198 | Arguments<'_>
199 | Cow<'static, str>
200 | Nonce
201 | Oco<'static, str>
202 | Rc
203 | TextProp
204 | and $N others
205 | = note: required for `MissingValueAfterEq` to implement `IntoAttribute`
206 | note: required by a bound in `leptos::HtmlElement::::attr`
207 | --> $CARGO/leptos_dom-0.6.12/src/html.rs
208 | |
209 | | pub fn attr(
210 | | ---- required by a bound in this associated function
211 | ...
212 | | attr: impl IntoAttribute,
213 | | ^^^^^^^^^^^^^ required by this bound in `HtmlElement::::attr`
214 |
--------------------------------------------------------------------------------
/tests/ui/errors/misc_partial.rs:
--------------------------------------------------------------------------------
1 | use leptos_mview::mview;
2 |
3 | fn invalid_value() {
4 | _ = mview! {
5 | div class:x={true} {
6 | span class=test
7 | }
8 | }
9 | }
10 |
11 | fn incomplete_directive() {
12 | _ = mview! {
13 | div class:x={true} {
14 | span class:
15 | }
16 | }
17 | }
18 |
19 | fn main() {}
20 |
--------------------------------------------------------------------------------
/tests/ui/errors/misc_partial.stderr:
--------------------------------------------------------------------------------
1 | error: expected value after =
2 | --> tests/ui/errors/misc_partial.rs:6:24
3 | |
4 | 6 | span class=test
5 | | ^^^^
6 | |
7 | = help: you may have meant to wrap this in braces
8 |
9 | error: unterminated element
10 | --> tests/ui/errors/misc_partial.rs:6:13
11 | |
12 | 6 | span class=test
13 | | ^^^^
14 | |
15 | = help: add a `;` to terminate the element with no children
16 |
17 | error: unexpected end of input, expected a kebab-cased ident
18 | --> tests/ui/errors/misc_partial.rs:15:9
19 | |
20 | 15 | }
21 | | ^
22 |
23 | error[E0277]: the trait bound `MissingValueAfterEq: IntoAttribute` is not satisfied
24 | --> tests/ui/errors/misc_partial.rs:6:24
25 | |
26 | 4 | _ = mview! {
27 | | _________-
28 | 5 | | div class:x={true} {
29 | 6 | | span class=test
30 | | | ^^^^ the trait `Fn()` is not implemented for `MissingValueAfterEq`, which is required by `MissingValueAfterEq: IntoAttribute`
31 | 7 | | }
32 | 8 | | }
33 | | |_____- required by a bound introduced by this call
34 | |
35 | = help: the following other types implement trait `IntoAttribute`:
36 | &'static str
37 | &std::string::String
38 | Arguments<'_>
39 | Cow<'static, str>
40 | Nonce
41 | Oco<'static, str>
42 | Rc
43 | TextProp
44 | and $N others
45 | = note: required for `MissingValueAfterEq` to implement `IntoAttribute`
46 | note: required by a bound in `leptos::HtmlElement::::attr`
47 | --> $CARGO/leptos_dom-0.6.12/src/html.rs
48 | |
49 | | pub fn attr(
50 | | ---- required by a bound in this associated function
51 | ...
52 | | attr: impl IntoAttribute,
53 | | ^^^^^^^^^^^^^ required by this bound in `HtmlElement::::attr`
54 |
--------------------------------------------------------------------------------
/tests/ui/errors/no_children_after_closure.rs:
--------------------------------------------------------------------------------
1 | use leptos::*;
2 | use leptos_mview::mview;
3 |
4 | fn main() {
5 | mview! {
6 | Await
7 | future=[async { 1 }]
8 | |data| "no"
9 | };
10 | }
--------------------------------------------------------------------------------
/tests/ui/errors/no_children_after_closure.stderr:
--------------------------------------------------------------------------------
1 | error: expected children block after closure arguments
2 | --> tests/ui/errors/no_children_after_closure.rs:8:16
3 | |
4 | 8 | |data| "no"
5 | | ^^^^
6 |
7 | warning: use of deprecated method `leptos::AwaitPropsBuilder::::build`: Missing required field children
8 | --> tests/ui/errors/no_children_after_closure.rs:6:9
9 | |
10 | 6 | Await
11 | | ^^^^^
12 | |
13 | = note: `#[warn(deprecated)]` on by default
14 |
15 | error[E0061]: this method takes 1 argument but 0 arguments were supplied
16 | --> tests/ui/errors/no_children_after_closure.rs:6:9
17 | |
18 | 6 | Await
19 | | ^^^^^ an argument of type `AwaitPropsBuilder_Error_Missing_required_field_children` is missing
20 | |
21 | note: method defined here
22 | --> $CARGO/leptos-0.6.12/src/await_.rs
23 | |
24 | | #[component]
25 | | ^^^^^^^^^^^^
26 | = note: this error originates in the derive macro `::leptos::typed_builder_macro::TypedBuilder` (in Nightly builds, run with -Z macro-backtrace for more info)
27 | help: provide the argument
28 | |
29 | 6 | Await(/* AwaitPropsBuilder_Error_Missing_required_field_children */)
30 | | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
31 |
--------------------------------------------------------------------------------
/tests/ui/errors/non_str_child.rs:
--------------------------------------------------------------------------------
1 | use leptos_mview::mview;
2 |
3 | fn main() {
4 | mview! {
5 | div { 3 }
6 | };
7 | }
8 |
--------------------------------------------------------------------------------
/tests/ui/errors/non_str_child.stderr:
--------------------------------------------------------------------------------
1 | error: only string literals are allowed in children
2 | --> tests/ui/errors/non_str_child.rs:5:15
3 | |
4 | 5 | div { 3 }
5 | | ^
6 |
--------------------------------------------------------------------------------
/tests/ui/errors/return_expression.rs:
--------------------------------------------------------------------------------
1 | use leptos_mview::mview;
2 |
3 | fn main() {
4 | // should not get an "unexpected end of macro invocation"
5 | let expr = mview! {
6 | div class=;
7 | };
8 | }
--------------------------------------------------------------------------------
/tests/ui/errors/return_expression.stderr:
--------------------------------------------------------------------------------
1 | error: expected value after =
2 | --> tests/ui/errors/return_expression.rs:6:19
3 | |
4 | 6 | div class=;
5 | | ^
6 |
7 | error[E0277]: the trait bound `MissingValueAfterEq: IntoAttribute` is not satisfied
8 | --> tests/ui/errors/return_expression.rs:6:19
9 | |
10 | 5 | let expr = mview! {
11 | | ________________-
12 | 6 | | div class=;
13 | | | ^ the trait `Fn()` is not implemented for `MissingValueAfterEq`, which is required by `MissingValueAfterEq: IntoAttribute`
14 | 7 | | };
15 | | |_____- required by a bound introduced by this call
16 | |
17 | = help: the following other types implement trait `IntoAttribute`:
18 | &'static str
19 | &std::string::String
20 | Arguments<'_>
21 | Cow<'static, str>
22 | Nonce
23 | Oco<'static, str>
24 | Rc
25 | TextProp
26 | and $N others
27 | = note: required for `MissingValueAfterEq` to implement `IntoAttribute`
28 | note: required by a bound in `leptos::HtmlElement::::attr`
29 | --> $CARGO/leptos_dom-0.6.12/src/html.rs
30 | |
31 | | pub fn attr(
32 | | ---- required by a bound in this associated function
33 | ...
34 | | attr: impl IntoAttribute,
35 | | ^^^^^^^^^^^^^ required by this bound in `HtmlElement::::attr`
36 |
--------------------------------------------------------------------------------
/tests/ui/errors/slot_builder_spans.rs:
--------------------------------------------------------------------------------
1 | //! Testing that there are no errors that cause the entire macro to error (i.e.
2 | //! call-site error).
3 | //!
4 | //! This file is for testing on the slot itself, see `com_builder_spans` for
5 | //! testing on components.
6 |
7 | use leptos::*;
8 | use leptos_mview::mview;
9 |
10 | #[slot]
11 | struct SChildren {
12 | an_attr: i32,
13 | children: ChildrenFn,
14 | }
15 |
16 | #[component]
17 | fn TakesSChildren(s_children: SChildren) -> impl IntoView { let _ = s_children; }
18 |
19 | fn missing_args() {
20 | _ = mview! {
21 | TakesSChildren {
22 | slot:SChildren { "hi" }
23 | }
24 | };
25 | }
26 |
27 | fn incorrect_arg_value() {
28 | _ = mview! {
29 | TakesSChildren { slot:SChildren an_attr="no" { "what" } }
30 | };
31 | }
32 |
33 | fn incorrect_closure_to_children() {
34 | let s = String::new();
35 | _ = mview! {
36 | TakesSChildren {
37 | slot:SChildren an_attr=1 |s| { "this is " {s} }
38 | }
39 | };
40 | }
41 |
42 | #[slot]
43 | struct SNoChildren {
44 | an_attr: i32,
45 | }
46 |
47 | #[component]
48 | fn TakesSNoChildren(s_no_children: SNoChildren) -> impl IntoView { let _ = s_no_children; }
49 |
50 | fn incorrect_children() {
51 | _ = mview! {
52 | TakesSNoChildren {
53 | slot:SNoChildren an_attr=5 { "hey!" }
54 | }
55 | };
56 | }
57 |
58 | #[slot]
59 | struct SClosureChildren {
60 | children: Callback,
61 | }
62 |
63 | #[component]
64 | fn TakesSClosureChildren(s_closure_children: SClosureChildren) -> impl IntoView {
65 | let _ = s_closure_children;
66 | }
67 |
68 | // FIXME: these spans aren't ideal, but difficult to change without cluttering
69 | // the hover tooltips
70 | fn missing_closure_to_children() {
71 | _ = mview! {
72 | TakesSClosureChildren {
73 | slot:SClosureChildren { "hey!" }
74 | }
75 | };
76 | }
77 |
78 | fn main() {}
79 |
--------------------------------------------------------------------------------
/tests/ui/errors/slot_builder_spans.stderr:
--------------------------------------------------------------------------------
1 | warning: use of deprecated method `SChildrenBuilder::<((), __children)>::build`: Missing required field an_attr
2 | --> tests/ui/errors/slot_builder_spans.rs:22:18
3 | |
4 | 22 | slot:SChildren { "hi" }
5 | | ^^^^^^^^^
6 | |
7 | = note: `#[warn(deprecated)]` on by default
8 |
9 | error[E0061]: this method takes 1 argument but 0 arguments were supplied
10 | --> tests/ui/errors/slot_builder_spans.rs:22:18
11 | |
12 | 22 | slot:SChildren { "hi" }
13 | | ^^^^^^^^^ an argument of type `SChildrenBuilder_Error_Missing_required_field_an_attr` is missing
14 | |
15 | note: method defined here
16 | --> tests/ui/errors/slot_builder_spans.rs:10:1
17 | |
18 | 10 | #[slot]
19 | | ^^^^^^^
20 | = note: this error originates in the derive macro `::leptos::typed_builder_macro::TypedBuilder` (in Nightly builds, run with -Z macro-backtrace for more info)
21 | help: provide the argument
22 | |
23 | 22 | slot:SChildren(/* SChildrenBuilder_Error_Missing_required_field_an_attr */) { "hi" }
24 | | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
25 |
26 | error[E0308]: mismatched types
27 | --> tests/ui/errors/slot_builder_spans.rs:29:49
28 | |
29 | 29 | TakesSChildren { slot:SChildren an_attr="no" { "what" } }
30 | | ------- ^^^^ expected `i32`, found `&str`
31 | | |
32 | | arguments to this method are incorrect
33 | |
34 | note: method defined here
35 | --> tests/ui/errors/slot_builder_spans.rs:12:5
36 | |
37 | 12 | an_attr: i32,
38 | | ^^^^^^^-----
39 |
40 | error[E0308]: mismatched types
41 | --> tests/ui/errors/slot_builder_spans.rs:37:38
42 | |
43 | 37 | slot:SChildren an_attr=1 |s| { "this is " {s} }
44 | | ^^^ expected `Rc Fragment>`, found closure
45 | |
46 | = note: expected struct `Rc<(dyn std::ops::Fn() -> Fragment + 'static)>`
47 | found closure `{closure@$DIR/tests/ui/errors/slot_builder_spans.rs:37:38: 37:41}`
48 |
49 | error[E0599]: no method named `children` found for struct `SNoChildrenBuilder` in the current scope
50 | --> tests/ui/errors/slot_builder_spans.rs:53:42
51 | |
52 | 42 | #[slot]
53 | | ------- method `children` not found for this struct
54 | ...
55 | 51 | _ = mview! {
56 | | _________-
57 | 52 | | TakesSNoChildren {
58 | 53 | | slot:SNoChildren an_attr=5 { "hey!" }
59 | | | -^^^^^^ method not found in `SNoChildrenBuilder<((i32,),)>`
60 | | |_________________________________________|
61 | |
62 |
63 | error[E0277]: the trait bound `leptos::Callback: ToChildren<{closure@$DIR/tests/ui/errors/slot_builder_spans.rs:73:37: 73:43}>` is not satisfied
64 | --> tests/ui/errors/slot_builder_spans.rs:71:9
65 | |
66 | 71 | _ = mview! {
67 | | _________^
68 | 72 | | TakesSClosureChildren {
69 | 73 | | slot:SClosureChildren { "hey!" }
70 | 74 | | }
71 | 75 | | };
72 | | |_____^ the trait `ToChildren<{closure@$DIR/tests/ui/errors/slot_builder_spans.rs:73:37: 73:43}>` is not implemented for `leptos::Callback`
73 | |
74 | = help: the following other types implement trait `ToChildren`:
75 | Box<(dyn FnMut() -> Fragment + 'static)>
76 | Box<(dyn FnOnce() -> Fragment + 'static)>
77 | Box<(dyn std::ops::Fn() -> Fragment + 'static)>
78 | Rc<(dyn std::ops::Fn() -> Fragment + 'static)>
79 | = note: this error originates in the macro `mview` (in Nightly builds, run with -Z macro-backtrace for more info)
80 |
--------------------------------------------------------------------------------
/tests/ui/errors/slot_unsupported_dirs.rs:
--------------------------------------------------------------------------------
1 | use leptos::*;
2 | use leptos_mview::mview;
3 |
4 | #[slot]
5 | struct Nothing {}
6 |
7 | #[component]
8 | fn TakesNothing(nothing: Nothing) -> impl IntoView { let _ = nothing; }
9 |
10 | fn try_bad_dirs() {
11 | let attrs: Vec<(&'static str, Attribute)> = Vec::new();
12 | let _spread = mview! {
13 | TakesNothing {
14 | slot:Nothing {..attrs};
15 | }
16 | };
17 |
18 | let _on = mview! {
19 | TakesNothing {
20 | slot:Nothing on:click={|_| ()};
21 | }
22 | };
23 |
24 | let _attr = mview! {
25 | TakesNothing {
26 | slot:Nothing attr:something="something";
27 | }
28 | };
29 |
30 | fn a_directive(_el: HtmlElement) {}
31 | let _use = mview! {
32 | TakesNothing {
33 | slot:Nothing use:a_directive;
34 | }
35 | };
36 |
37 | let _prop = mview! {
38 | TakesNothing {
39 | slot:Nothing prop:value="1";
40 | }
41 | };
42 | }
43 |
44 | fn main() {}
45 |
--------------------------------------------------------------------------------
/tests/ui/errors/slot_unsupported_dirs.stderr:
--------------------------------------------------------------------------------
1 | error: spread syntax is not supported on slots
2 | --> tests/ui/errors/slot_unsupported_dirs.rs:14:26
3 | |
4 | 14 | slot:Nothing {..attrs};
5 | | ^^^^^^^^^
6 |
7 | error: `on:` is not supported on slots
8 | --> tests/ui/errors/slot_unsupported_dirs.rs:20:26
9 | |
10 | 20 | slot:Nothing on:click={|_| ()};
11 | | ^^
12 |
13 | error: `attr:` is not supported on slots
14 | --> tests/ui/errors/slot_unsupported_dirs.rs:26:26
15 | |
16 | 26 | slot:Nothing attr:something="something";
17 | | ^^^^
18 |
19 | error: `use:` is not supported on slots
20 | --> tests/ui/errors/slot_unsupported_dirs.rs:33:26
21 | |
22 | 33 | slot:Nothing use:a_directive;
23 | | ^^^
24 |
25 | error: `prop:` is not supported on components/slots
26 | --> tests/ui/errors/slot_unsupported_dirs.rs:39:26
27 | |
28 | 39 | slot:Nothing prop:value="1";
29 | | ^^^^
30 |
31 | warning: unused variable: `attrs`
32 | --> tests/ui/errors/slot_unsupported_dirs.rs:11:9
33 | |
34 | 11 | let attrs: Vec<(&'static str, Attribute)> = Vec::new();
35 | | ^^^^^ help: if this is intentional, prefix it with an underscore: `_attrs`
36 | |
37 | = note: `#[warn(unused_variables)]` on by default
38 |
--------------------------------------------------------------------------------
/tests/ui/errors/unsupported_attrs.rs:
--------------------------------------------------------------------------------
1 | use leptos::*;
2 | use leptos_mview::mview;
3 |
4 | fn style_on_component() {
5 | mview! {
6 | Component style:color="white";
7 | };
8 | }
9 |
10 | fn prop_on_component() {
11 | mview! {
12 | Component prop:value="1";
13 | };
14 | }
15 |
16 | fn attr_on_element() {
17 | mview! {
18 | input attr:class="no" type="text";
19 | };
20 | }
21 |
22 | fn clone_on_element() {
23 | let notcopy = String::new();
24 | mview! {
25 | div {
26 | span clone:notcopy {
27 | {notcopy.clone()}
28 | }
29 | }
30 | };
31 | }
32 |
33 | #[component]
34 | fn Component() -> impl IntoView {
35 | mview! {
36 | button;
37 | };
38 | }
39 |
40 | fn main() {}
41 |
--------------------------------------------------------------------------------
/tests/ui/errors/unsupported_attrs.stderr:
--------------------------------------------------------------------------------
1 | error: `style:` is not supported on components/slots
2 | --> tests/ui/errors/unsupported_attrs.rs:6:19
3 | |
4 | 6 | Component style:color="white";
5 | | ^^^^^
6 |
7 | error: `prop:` is not supported on components/slots
8 | --> tests/ui/errors/unsupported_attrs.rs:12:19
9 | |
10 | 12 | Component prop:value="1";
11 | | ^^^^
12 |
13 | error: `attr:` is not supported on elements
14 | --> tests/ui/errors/unsupported_attrs.rs:18:15
15 | |
16 | 18 | input attr:class="no" type="text";
17 | | ^^^^
18 |
19 | error: `clone:` is not supported on elements
20 | --> tests/ui/errors/unsupported_attrs.rs:26:18
21 | |
22 | 26 | span clone:notcopy {
23 | | ^^^^^
24 |
--------------------------------------------------------------------------------
/tests/ui/errors/unterminated_element.rs:
--------------------------------------------------------------------------------
1 | use leptos_mview::mview;
2 |
3 | fn main() {
4 | mview! {
5 | input type="text"
6 | "hi"
7 | };
8 | }
9 |
--------------------------------------------------------------------------------
/tests/ui/errors/unterminated_element.stderr:
--------------------------------------------------------------------------------
1 | error: unknown attribute
2 | --> tests/ui/errors/unterminated_element.rs:6:9
3 | |
4 | 6 | "hi"
5 | | ^^^^
6 |
7 | error: child elements not found
8 | --> tests/ui/errors/unterminated_element.rs:5:9
9 | |
10 | 5 | / input type="text"
11 | 6 | | "hi"
12 | | |____________^
13 | |
14 | = help: add a `;` at the end to terminate the element
15 |
--------------------------------------------------------------------------------
/tests/ui/errors/unterminated_element_error.rs:
--------------------------------------------------------------------------------
1 | use leptos_mview::mview;
2 |
3 | fn main() {
4 | _ = mview! {
5 | div {
6 | "something"
7 | input.input type="text"
8 | }
9 | };
10 | }
11 |
--------------------------------------------------------------------------------
/tests/ui/errors/unterminated_element_error.stderr:
--------------------------------------------------------------------------------
1 | error: unterminated element
2 | --> tests/ui/errors/unterminated_element_error.rs:7:13
3 | |
4 | 7 | input.input type="text"
5 | | ^^^^^
6 | |
7 | = help: add a `;` to terminate the element with no children
8 |
--------------------------------------------------------------------------------
/tests/ui/errors/use_directive.rs:
--------------------------------------------------------------------------------
1 | use leptos::{html::AnyElement, HtmlElement};
2 | use leptos_mview::mview;
3 |
4 | fn no_arg_dir(_el: HtmlElement) {}
5 |
6 | fn arg_dir(_el: HtmlElement, _argument: i32) {}
7 |
8 | fn missing_argument() {
9 | _ = mview! {
10 | div use:arg_dir;
11 | };
12 | }
13 |
14 | fn extra_argument() {
15 | _ = mview! {
16 | span use:no_arg_dir=2;
17 | };
18 | }
19 |
20 | fn main() {}
21 |
--------------------------------------------------------------------------------
/tests/ui/errors/use_directive.stderr:
--------------------------------------------------------------------------------
1 | error[E0277]: the trait bound `i32: From<()>` is not satisfied
2 | --> tests/ui/errors/use_directive.rs:10:17
3 | |
4 | 10 | div use:arg_dir;
5 | | ^^^^^^^ the trait `From<()>` is not implemented for `i32`, which is required by `(): Into<_>`
6 | |
7 | = help: the following other types implement trait `From`:
8 | `i32` implements `From`
9 | `i32` implements `From`
10 | `i32` implements `From`
11 | `i32` implements `From`
12 | `i32` implements `From`
13 | = note: required for `()` to implement `Into`
14 |
15 | error[E0277]: the trait bound `(): From<{integer}>` is not satisfied
16 | --> tests/ui/errors/use_directive.rs:16:29
17 | |
18 | 15 | _ = mview! {
19 | | _________-
20 | 16 | | span use:no_arg_dir=2;
21 | | | ^ the trait `From<{integer}>` is not implemented for `()`, which is required by `{integer}: Into<_>`
22 | 17 | | };
23 | | |_____- required by a bound introduced by this call
24 | |
25 | = help: the following other types implement trait `From`:
26 | `(T, T)` implements `From<[T; 2]>`
27 | `(T, T, T)` implements `From<[T; 3]>`
28 | `(T, T, T, T)` implements `From<[T; 4]>`
29 | `(T, T, T, T, T)` implements `From<[T; 5]>`
30 | `(T, T, T, T, T, T)` implements `From<[T; 6]>`
31 | `(T, T, T, T, T, T, T)` implements `From<[T; 7]>`
32 | `(T, T, T, T, T, T, T, T)` implements `From<[T; 8]>`
33 | `(T, T, T, T, T, T, T, T, T)` implements `From<[T; 9]>`
34 | and $N others
35 | = note: required for `{integer}` to implement `Into<()>`
36 |
--------------------------------------------------------------------------------
/tests/ui/pass/many_braces.rs:
--------------------------------------------------------------------------------
1 | #![deny(unused_braces)]
2 |
3 | use leptos_mview::mview;
4 |
5 | fn main() {
6 | _ = mview! {
7 | div a={3} b={"aaaaa"} {
8 | {1234}
9 | span class={"braces not needed"} { "hi" }
10 | }
11 | };
12 |
13 | _ = mview! {
14 | button class:primary-200={true};
15 | button on:click={move |_| println!("hi")} {
16 | span
17 | style:background-color={"black"}
18 | style:color="white"
19 | {
20 | "inverted"
21 | }
22 | }
23 | };
24 | }
25 |
--------------------------------------------------------------------------------
/tests/ui/pass/use_directive.rs:
--------------------------------------------------------------------------------
1 | use leptos::{*, html::AnyElement};
2 | use leptos_mview::mview;
3 |
4 | fn no_arg_dir(_el: HtmlElement) {}
5 |
6 | fn arg_dir(_el: HtmlElement, _argument: i32) {}
7 |
8 | fn main() {
9 | _ = mview! {
10 | div use:no_arg_dir {
11 | span use:arg_dir=10;
12 | }
13 | };
14 |
15 | _ = mview! {
16 | Component use:no_arg_dir;
17 | Component use:arg_dir=300;
18 | };
19 | }
20 |
21 | #[component]
22 | fn Component() -> impl IntoView {
23 | mview! { button { "hi" } }
24 | }
25 |
26 | #[component]
27 | fn Spreadable(#[prop(attrs)] attrs: Vec<(&'static str, Attribute)>) -> impl IntoView {
28 | mview! {
29 | div {..attrs};
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/tests/utils/mod.rs:
--------------------------------------------------------------------------------
1 | #![allow(dead_code)]
2 |
3 | use leptos::prelude::*;
4 |
5 | #[track_caller]
6 | pub fn check_str<'a>(component: impl IntoView, contains: impl Into>) {
7 | let component_str = component.into_view().to_html();
8 | match contains.into() {
9 | Contains::Str(s) => {
10 | assert!(
11 | component_str.contains(s),
12 | "expected \"{s}\" to be found in the component render.\n\
13 | Found:\n\
14 | {component_str}"
15 | )
16 | }
17 | Contains::All(a) => a.into_iter().for_each(|s| {
18 | assert!(
19 | component_str.contains(s),
20 | "expected all of {a:?} to be found in the component render.\n\
21 | did not find {s:?}\n\
22 | Found:\n\
23 | {component_str}"
24 | )
25 | }),
26 | Contains::Not(s) => {
27 | assert!(
28 | !component_str.contains(s),
29 | "expected \"{s}\" to not be found in the component render.\n\
30 | Found:\n\
31 | {component_str}"
32 | )
33 | }
34 | Contains::NoneOf(a) => a.into_iter().for_each(|s| {
35 | assert!(
36 | !component_str.contains(s),
37 | "expected none of {a:?} to be found in the component render.\n\
38 | found {s:?} in the component:\n\
39 | {component_str}"
40 | )
41 | }),
42 | Contains::AllOfNoneOf([a, n]) => {
43 | a.into_iter().for_each(|s| {
44 | assert!(
45 | component_str.contains(s),
46 | "expected all of {a:?} to be found in the component render.\n\
47 | did not find {s:?}\n\
48 | Found:\n\
49 | {component_str}"
50 | );
51 | });
52 | n.into_iter().for_each(|s| {
53 | assert!(
54 | !component_str.contains(s),
55 | "expected none of {n:?} to be found in the component render.\n\
56 | found {s:?} in the component:\n\
57 | {component_str}"
58 | );
59 | });
60 | }
61 | };
62 | }
63 |
64 | pub enum Contains<'a> {
65 | Str(&'a str),
66 | All(&'a [&'a str]),
67 | Not(&'a str),
68 | NoneOf(&'a [&'a str]),
69 | AllOfNoneOf([&'a [&'a str]; 2]),
70 | }
71 |
72 | impl<'a> From<&'a str> for Contains<'a> {
73 | fn from(value: &'a str) -> Self { Self::Str(value) }
74 | }
75 |
76 | impl<'a> From<&'a [&'a str]> for Contains<'a> {
77 | fn from(value: &'a [&'a str]) -> Self { Self::All(value) }
78 | }
79 |
--------------------------------------------------------------------------------
/tests/values.rs:
--------------------------------------------------------------------------------
1 | use leptos::prelude::*;
2 | use leptos_mview::mview;
3 | use utils::check_str;
4 | mod utils;
5 |
6 | #[test]
7 | fn f_value() {
8 | let yes = || true;
9 | let no = || false;
10 | let r = mview! {
11 | div aria-selected=f["{}", yes()] data-not-selected=f["{}", no()];
12 | };
13 |
14 | check_str(r, r#"