Skip to content
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

Box VTag to reduce size disparity between VNode variants #675

Merged
merged 40 commits into from
Oct 14, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
6f8d07a
Box VComp to reduce size disparity between VNode variants
hgzimmerman Sep 30, 2019
ea7346c
revert changes
hgzimmerman Oct 14, 2019
1ec8adc
handle box in library
hgzimmerman Oct 14, 2019
f446f2e
adjust macro to accomodate boxing vtags
hgzimmerman Oct 14, 2019
2b7ed68
fix markdown vtag generation in crm example
hgzimmerman Oct 14, 2019
b4eee87
add new goal to crm readme
hgzimmerman Oct 14, 2019
afac09c
change macro to use from to convert vtag instead of explicitly boxing
hgzimmerman Oct 14, 2019
6ca17ce
bump
hgzimmerman Oct 14, 2019
a4f8c5d
Derive PartialEq for Classes (#680)
hgzimmerman Oct 7, 2019
f531ea4
bump to stdweb 0.4.19 (#683)
ctaggart Oct 7, 2019
5bf8766
Use trait objects with explicit `dyn` in examples (#687)
benreyn Oct 8, 2019
5112be6
Fix multi_thread example (#689)
jstarry Oct 9, 2019
d5c7b83
Bump stdweb to 0.4.20 (#694)
jstarry Oct 11, 2019
a44b8e8
Bump wasm bindgen to 0.2.50 (#695)
jstarry Oct 11, 2019
90e4ff0
Variable renames (#696)
jstarry Oct 12, 2019
0ecd9f1
Fix diff for VText nodes (#697)
jstarry Oct 12, 2019
99dc5ae
Fix VTag attribute updates (#698)
jstarry Oct 13, 2019
f01527a
Pin ryu dependency to 1.0.0 for emscripten targets (#703)
jstarry Oct 13, 2019
20be32c
Stop force installing wasm-bindgen-cli in CI (#701)
jstarry Oct 13, 2019
808aebd
Add CI caching for nvm (#700)
jstarry Oct 13, 2019
53bbd7e
Optimize the default `change` implementation (#690)
kellytk Oct 13, 2019
e19ec02
Forbid missing Debug implementations (#673)
hgzimmerman Oct 13, 2019
e6060a5
Improve compile error for non-string attributes (#710)
jstarry Oct 14, 2019
c0a1e30
Fix travis (#711)
jstarry Oct 14, 2019
6e35bee
Use wasm32-unknown-unknown as the default build target (#702)
jstarry Oct 13, 2019
7e423dc
Use latest chromedriver (#708)
jstarry Oct 13, 2019
0f09bdc
Enable clippy in CI (#706)
jstarry Oct 13, 2019
0d29397
Cleanup run tests CI script (#709)
jstarry Oct 13, 2019
7836b58
Speed up cache (#707)
jstarry Oct 14, 2019
2c5fbb1
Remove git files from travis cache
jstarry Oct 14, 2019
aea3e15
Box VComp to reduce size disparity between VNode variants
hgzimmerman Sep 30, 2019
22b049e
revert changes
hgzimmerman Oct 14, 2019
576ca2f
handle box in library
hgzimmerman Oct 14, 2019
5781fae
adjust macro to accomodate boxing vtags
hgzimmerman Oct 14, 2019
16c3736
fix markdown vtag generation in crm example
hgzimmerman Oct 14, 2019
cdad360
add new goal to crm readme
hgzimmerman Oct 14, 2019
7b2a1ef
change macro to use from to convert vtag instead of explicitly boxing
hgzimmerman Oct 14, 2019
fd1f0fd
Merge branch 'master' of https://github.com/yewstack/yew into box_vcomp
hgzimmerman Oct 14, 2019
8ef25d9
Merge branch 'box_vcomp' of github.com:hgzimmerman/yew into box_vcomp
hgzimmerman Oct 14, 2019
153e282
remove large_enum_variant allow lint
hgzimmerman Oct 14, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/macro/src/html_tree/html_tag/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl ToTokens for HtmlTag {
#vtag.add_attributes(vec![#((#attr_labels.to_owned(), (#attr_values).to_string())),*]);
#vtag.add_listeners(vec![#(::std::boxed::Box::new(#listeners)),*]);
#vtag.add_children(vec![#(#children),*]);
::yew::virtual_dom::VNode::VTag(#vtag)
::yew::virtual_dom::VNode::VTag(Box::new(#vtag))
jstarry marked this conversation as resolved.
Show resolved Hide resolved
}});
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/crm/src/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ where
}

if elems.len() == 1 {
VNode::VTag(elems.pop().unwrap())
VNode::VTag(Box::new(elems.pop().unwrap()))
} else {
html! {
<div>{ for elems.into_iter() }</div>
Expand Down
4 changes: 2 additions & 2 deletions src/virtual_dom/vnode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use stdweb::web::{Element, INode, Node};
/// Bind virtual element to a DOM reference.
pub enum VNode<COMP: Component> {
/// A bind between `VTag` and `Element`.
VTag(VTag<COMP>),
VTag(Box<VTag<COMP>>),
/// A bind between `VText` and `TextNode`.
VText(VText<COMP>),
/// A bind between `VComp` and `Element`.
Expand Down Expand Up @@ -86,7 +86,7 @@ impl<COMP: Component> From<VList<COMP>> for VNode<COMP> {

impl<COMP: Component> From<VTag<COMP>> for VNode<COMP> {
fn from(vtag: VTag<COMP>) -> Self {
VNode::VTag(vtag)
VNode::VTag(Box::new(vtag))
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/virtual_dom/vtag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ impl<COMP: Component> VTag<COMP> {
/// Otherwise just add everything.
fn diff_classes<'a>(
&'a self,
ancestor: &'a Option<Self>,
ancestor: &'a Option<Box<Self>>,
) -> impl Iterator<Item = Patch<&'a str, ()>> + 'a {
let to_add = {
let all_or_nothing = not(ancestor)
Expand Down Expand Up @@ -210,7 +210,7 @@ impl<COMP: Component> VTag<COMP> {
/// the values are different.
fn diff_attributes<'a>(
&'a self,
ancestor: &'a Option<Self>,
ancestor: &'a Option<Box<Self>>,
) -> impl Iterator<Item = Patch<&'a str, &'a str>> + 'a {
// Only change what is necessary.
let to_add_or_replace =
Expand All @@ -236,7 +236,7 @@ impl<COMP: Component> VTag<COMP> {
}

/// Similar to `diff_attributers` except there is only a single `kind`.
fn diff_kind<'a>(&'a self, ancestor: &'a Option<Self>) -> Option<Patch<&'a str, ()>> {
fn diff_kind<'a>(&'a self, ancestor: &'a Option<Box<Self>>) -> Option<Patch<&'a str, ()>> {
match (
self.kind.as_ref(),
ancestor.as_ref().and_then(|anc| anc.kind.as_ref()),
Expand All @@ -255,7 +255,7 @@ impl<COMP: Component> VTag<COMP> {
}

/// Almost identical in spirit to `diff_kind`
fn diff_value<'a>(&'a self, ancestor: &'a Option<Self>) -> Option<Patch<&'a str, ()>> {
fn diff_value<'a>(&'a self, ancestor: &'a Option<Box<Self>>) -> Option<Patch<&'a str, ()>> {
match (
self.value.as_ref(),
ancestor.as_ref().and_then(|anc| anc.value.as_ref()),
Expand All @@ -273,7 +273,7 @@ impl<COMP: Component> VTag<COMP> {
}
}

fn apply_diffs(&mut self, element: &Element, ancestor: &Option<Self>) {
fn apply_diffs(&mut self, element: &Element, ancestor: &Option<Box<Self>>) {
// Update parameters
let changes = self.diff_classes(ancestor);
for change in changes {
Expand Down