Skip to content

Commit 61a64aa

Browse files
committed
Fixed a bug in window events. Top-level children now mount direclty to the mount point instead of an intermediate element
1 parent 5476109 commit 61a64aa

File tree

17 files changed

+96
-327
lines changed

17 files changed

+96
-327
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## v0.3.1
4+
- `Top level view functions now return `Vec<El<Ms>>` instead of `El<Ms>`, mounted directly to
5+
the mount point. (Breaking)
6+
- `push_route()` can now accept a `Vec<&str>`, depreciating `push_path()`.
7+
- Fixed a bug where window events couldn't be enabled on initialization
8+
39
## v0.3.0
410
- `update` function now takes a mutable ref of the model. (Breaking)
511
- `Update` (update's return type) is now a struct. (Breaking)

Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "seed"
3-
version = "0.3.0"
3+
version = "0.3.1"
44
description = "A Rust framework for creating web apps, using WebAssembly"
55
authors = ["DavidOConnor <[email protected]>"]
66
license = "MIT"
@@ -79,7 +79,6 @@ members = [
7979
"examples/todomvc",
8080
"examples/window_events",
8181
"examples/websocket",
82-
"proc_macros",
8382
]
8483

8584
exclude = [

README.md

+24-22
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ fn success_level(clicks: i32) -> El<Msg> {
145145
}
146146

147147
/// The top-level component we pass to the virtual dom.
148-
fn view(model: &Model) -> El<Msg> {
148+
fn view(model: &Model) -> Vec<El<Msg>> {
149149
let plural = if model.count == 1 {""} else {"s"};
150150

151151
// Attrs, Style, Events, and children may be defined separately.
@@ -155,27 +155,29 @@ fn view(model: &Model) -> El<Msg> {
155155
"text-align" => "center"
156156
};
157157

158-
div![ outer_style,
159-
h1![ "The Grand Total" ],
160-
div![
161-
style!{
162-
// Example of conditional logic in a style.
163-
"color" => if model.count > 4 {"purple"} else {"gray"};
164-
// When passing numerical values to style!, "px" is implied.
165-
"border" => "2px solid #004422"; "padding" => 20
166-
},
167-
// We can use normal Rust code and comments in the view.
168-
h3![ format!("{} {}{} so far", model.count, model.what_we_count, plural) ],
169-
button![ simple_ev(Ev::Click, Msg::Increment), "+" ],
170-
button![ simple_ev(Ev::Click, Msg::Decrement), "-" ],
171-
172-
// Optionally-displaying an element
173-
if model.count >= 10 { h2![ style!{"padding" => 50}, "Nice!" ] } else { seed::empty() }
174-
],
175-
success_level(model.count), // Incorporating a separate component
176-
177-
h3![ "What precisely is it we're counting?" ],
178-
input![ attrs!{At::Value => model.what_we_count}, input_ev(Ev::Input, Msg::ChangeWWC) ]
158+
vec![
159+
div![ outer_style,
160+
h1![ "The Grand Total" ],
161+
div![
162+
style!{
163+
// Example of conditional logic in a style.
164+
"color" => if model.count > 4 {"purple"} else {"gray"};
165+
// When passing numerical values to style!, "px" is implied.
166+
"border" => "2px solid #004422"; "padding" => 20
167+
},
168+
// We can use normal Rust code and comments in the view.
169+
h3![ format!("{} {}{} so far", model.count, model.what_we_count, plural) ],
170+
button![ simple_ev(Ev::Click, Msg::Increment), "+" ],
171+
button![ simple_ev(Ev::Click, Msg::Decrement), "-" ],
172+
173+
// Optionally-displaying an element
174+
if model.count >= 10 { h2![ style!{"padding" => 50}, "Nice!" ] } else { seed::empty() }
175+
],
176+
success_level(model.count), // Incorporating a separate component
177+
178+
h3![ "What precisely is it we're counting?" ],
179+
input![ attrs!{At::Value => model.what_we_count}, input_ev(Ev::Input, Msg::ChangeWWC) ]
180+
]
179181
]
180182
}
181183

examples/layered_structure/Cargo.toml

-13
This file was deleted.

examples/layered_structure/README.md

-3
This file was deleted.

examples/layered_structure/build.ps1

-5
This file was deleted.

examples/layered_structure/build.sh

-7
This file was deleted.

examples/layered_structure/index.html

-36
This file was deleted.

examples/layered_structure/pkg/.keep

Whitespace-only changes.

examples/layered_structure/serve.py

-32
This file was deleted.

examples/layered_structure/src/lib.rs

-99
This file was deleted.

examples/todomvc/src/lib.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,7 @@ fn view(model: &Model) -> Vec<El<Msg>> {
312312
ul![class!["todo-list"], todo_els]
313313
]
314314
} else {
315-
// seed::empty()
316-
span![]
315+
seed::empty()
317316
};
318317

319318
vec![
@@ -335,8 +334,7 @@ fn view(model: &Model) -> Vec<El<Msg>> {
335334
if model.active_count() > 0 || model.completed_count() > 0 {
336335
footer(&model)
337336
} else {
338-
// seed::empty()
339-
span![]
337+
seed::empty()
340338
},
341339
]
342340
}

proc_macros/Cargo.toml

-10
This file was deleted.

proc_macros/src/lib.rs

-11
This file was deleted.

src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ pub mod tests {
134134
}
135135
}
136136

137-
fn view(_model: &Model) -> El<Msg> {
138-
div!["Hello world"]
137+
fn view(_model: &Model) -> Vec<El<Msg>> {
138+
vec![div!["Hello world"]]
139139
}
140140

141141
fn window_events(_model: &Model) -> Vec<seed::dom_types::Listener<Msg>> {

0 commit comments

Comments
 (0)