fix remaining core tests
This commit is contained in:
1 parent
51441b44ca
commit
b039d6acc0
11 files changed
+174
-170
No files matched your search
@@ -62,7 +62,7 @@ fn keyed_diffing_out_of_order_adds() {
|
|||||||
render!({ order.iter().map(|i| render!(div { key: "{i}" })) })
|
render!({ order.iter().map(|i| render!(div { key: "{i}" })) })
|
||||||
});
|
});
|
||||||
|
|
||||||
_ = dom.rebuild(&mut dioxus_core::NoOpMutations);
|
dom.rebuild(&mut dioxus_core::NoOpMutations);
|
||||||
|
|
||||||
dom.mark_dirty(ScopeId::ROOT);
|
dom.mark_dirty(ScopeId::ROOT);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@@ -88,7 +88,7 @@ fn keyed_diffing_out_of_order_adds_3() {
|
|||||||
render!({ order.iter().map(|i| render!(div { key: "{i}" })) })
|
render!({ order.iter().map(|i| render!(div { key: "{i}" })) })
|
||||||
});
|
});
|
||||||
|
|
||||||
_ = dom.rebuild(&mut dioxus_core::NoOpMutations);
|
dom.rebuild(&mut dioxus_core::NoOpMutations);
|
||||||
|
|
||||||
dom.mark_dirty(ScopeId::ROOT);
|
dom.mark_dirty(ScopeId::ROOT);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@@ -114,7 +114,7 @@ fn keyed_diffing_out_of_order_adds_4() {
|
|||||||
render!({ order.iter().map(|i| render!(div { key: "{i}" })) })
|
render!({ order.iter().map(|i| render!(div { key: "{i}" })) })
|
||||||
});
|
});
|
||||||
|
|
||||||
_ = dom.rebuild(&mut dioxus_core::NoOpMutations);
|
dom.rebuild(&mut dioxus_core::NoOpMutations);
|
||||||
|
|
||||||
dom.mark_dirty(ScopeId::ROOT);
|
dom.mark_dirty(ScopeId::ROOT);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@@ -140,7 +140,7 @@ fn keyed_diffing_out_of_order_adds_5() {
|
|||||||
render!({ order.iter().map(|i| render!(div { key: "{i}" })) })
|
render!({ order.iter().map(|i| render!(div { key: "{i}" })) })
|
||||||
});
|
});
|
||||||
|
|
||||||
_ = dom.rebuild(&mut dioxus_core::NoOpMutations);
|
dom.rebuild(&mut dioxus_core::NoOpMutations);
|
||||||
|
|
||||||
dom.mark_dirty(ScopeId::ROOT);
|
dom.mark_dirty(ScopeId::ROOT);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@@ -165,7 +165,7 @@ fn keyed_diffing_additions() {
|
|||||||
render!({ order.iter().map(|i| render!(div { key: "{i}" })) })
|
render!({ order.iter().map(|i| render!(div { key: "{i}" })) })
|
||||||
});
|
});
|
||||||
|
|
||||||
_ = dom.rebuild(&mut dioxus_core::NoOpMutations);
|
dom.rebuild(&mut dioxus_core::NoOpMutations);
|
||||||
|
|
||||||
dom.mark_dirty(ScopeId::ROOT);
|
dom.mark_dirty(ScopeId::ROOT);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@@ -190,7 +190,7 @@ fn keyed_diffing_additions_and_moves_on_ends() {
|
|||||||
render!({ order.iter().map(|i| render!(div { key: "{i}" })) })
|
render!({ order.iter().map(|i| render!(div { key: "{i}" })) })
|
||||||
});
|
});
|
||||||
|
|
||||||
_ = dom.rebuild(&mut dioxus_core::NoOpMutations);
|
dom.rebuild(&mut dioxus_core::NoOpMutations);
|
||||||
|
|
||||||
dom.mark_dirty(ScopeId::ROOT);
|
dom.mark_dirty(ScopeId::ROOT);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@@ -219,7 +219,7 @@ fn keyed_diffing_additions_and_moves_in_middle() {
|
|||||||
render!({ order.iter().map(|i| render!(div { key: "{i}" })) })
|
render!({ order.iter().map(|i| render!(div { key: "{i}" })) })
|
||||||
});
|
});
|
||||||
|
|
||||||
_ = dom.rebuild(&mut dioxus_core::NoOpMutations);
|
dom.rebuild(&mut dioxus_core::NoOpMutations);
|
||||||
|
|
||||||
// LIS: 4, 5, 6
|
// LIS: 4, 5, 6
|
||||||
dom.mark_dirty(ScopeId::ROOT);
|
dom.mark_dirty(ScopeId::ROOT);
|
||||||
@@ -253,7 +253,7 @@ fn controlled_keyed_diffing_out_of_order() {
|
|||||||
render!({ order.iter().map(|i| render!(div { key: "{i}" })) })
|
render!({ order.iter().map(|i| render!(div { key: "{i}" })) })
|
||||||
});
|
});
|
||||||
|
|
||||||
_ = dom.rebuild(&mut dioxus_core::NoOpMutations);
|
dom.rebuild(&mut dioxus_core::NoOpMutations);
|
||||||
|
|
||||||
// LIS: 5, 6
|
// LIS: 5, 6
|
||||||
dom.mark_dirty(ScopeId::ROOT);
|
dom.mark_dirty(ScopeId::ROOT);
|
||||||
@@ -287,7 +287,7 @@ fn controlled_keyed_diffing_out_of_order_max_test() {
|
|||||||
render!({ order.iter().map(|i| render!(div { key: "{i}" })) })
|
render!({ order.iter().map(|i| render!(div { key: "{i}" })) })
|
||||||
});
|
});
|
||||||
|
|
||||||
_ = dom.rebuild(&mut dioxus_core::NoOpMutations);
|
dom.rebuild(&mut dioxus_core::NoOpMutations);
|
||||||
|
|
||||||
dom.mark_dirty(ScopeId::ROOT);
|
dom.mark_dirty(ScopeId::ROOT);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@@ -316,7 +316,7 @@ fn remove_list() {
|
|||||||
render!({ order.iter().map(|i| render!(div { key: "{i}" })) })
|
render!({ order.iter().map(|i| render!(div { key: "{i}" })) })
|
||||||
});
|
});
|
||||||
|
|
||||||
_ = dom.rebuild(&mut dioxus_core::NoOpMutations);
|
dom.rebuild(&mut dioxus_core::NoOpMutations);
|
||||||
|
|
||||||
dom.mark_dirty(ScopeId::ROOT);
|
dom.mark_dirty(ScopeId::ROOT);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@@ -341,7 +341,7 @@ fn no_common_keys() {
|
|||||||
render!({ order.iter().map(|i| render!(div { key: "{i}" })) })
|
render!({ order.iter().map(|i| render!(div { key: "{i}" })) })
|
||||||
});
|
});
|
||||||
|
|
||||||
_ = dom.rebuild(&mut dioxus_core::NoOpMutations);
|
dom.rebuild(&mut dioxus_core::NoOpMutations);
|
||||||
|
|
||||||
dom.mark_dirty(ScopeId::ROOT);
|
dom.mark_dirty(ScopeId::ROOT);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|||||||
@@ -282,7 +282,7 @@ fn two_equal_fragments_are_equal_static() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
_ = dom.rebuild(&mut dioxus_core::NoOpMutations);
|
dom.rebuild(&mut dioxus_core::NoOpMutations);
|
||||||
assert!(dom.render_immediate_to_vec().edits.is_empty());
|
assert!(dom.render_immediate_to_vec().edits.is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,7 +296,7 @@ fn two_equal_fragments_are_equal() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
_ = dom.rebuild(&mut dioxus_core::NoOpMutations);
|
dom.rebuild(&mut dioxus_core::NoOpMutations);
|
||||||
assert!(dom.render_immediate_to_vec().edits.is_empty());
|
assert!(dom.render_immediate_to_vec().edits.is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use dioxus::prelude::*;
|
|||||||
#[test]
|
#[test]
|
||||||
fn catches_panic() {
|
fn catches_panic() {
|
||||||
let mut dom = VirtualDom::new(app);
|
let mut dom = VirtualDom::new(app);
|
||||||
_ = dom.rebuild(&mut dioxus_core::NoOpMutations);
|
dom.rebuild(&mut dioxus_core::NoOpMutations);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ fn events_propagate() {
|
|||||||
set_event_converter(Box::new(dioxus_html::SerializedHtmlEventConverter));
|
set_event_converter(Box::new(dioxus_html::SerializedHtmlEventConverter));
|
||||||
|
|
||||||
let mut dom = VirtualDom::new(app);
|
let mut dom = VirtualDom::new(app);
|
||||||
_ = dom.rebuild(&mut dioxus_core::NoOpMutations);
|
dom.rebuild(&mut dioxus_core::NoOpMutations);
|
||||||
|
|
||||||
// Top-level click is registered
|
// Top-level click is registered
|
||||||
dom.handle_event(
|
dom.handle_event(
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ fn manual_diffing() {
|
|||||||
let value = Arc::new(Mutex::new("Hello"));
|
let value = Arc::new(Mutex::new("Hello"));
|
||||||
let mut dom = VirtualDom::new_with_props(app, AppProps { value: value.clone() });
|
let mut dom = VirtualDom::new_with_props(app, AppProps { value: value.clone() });
|
||||||
|
|
||||||
let _ = dom.rebuild(&mut dioxus_core::NoOpMutations);
|
dom.rebuild(&mut dioxus_core::NoOpMutations);
|
||||||
|
|
||||||
*value.lock().unwrap() = "goodbye";
|
*value.lock().unwrap() = "goodbye";
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ fn events_generate() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let mut dom = VirtualDom::new(app);
|
let mut dom = VirtualDom::new(app);
|
||||||
_ = dom.rebuild(&mut dioxus_core::NoOpMutations);
|
dom.rebuild(&mut dioxus_core::NoOpMutations);
|
||||||
|
|
||||||
dom.handle_event(
|
dom.handle_event(
|
||||||
"click",
|
"click",
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ fn miri_rollover() {
|
|||||||
set_event_converter(Box::new(SerializedHtmlEventConverter));
|
set_event_converter(Box::new(SerializedHtmlEventConverter));
|
||||||
let mut dom = VirtualDom::new(app);
|
let mut dom = VirtualDom::new(app);
|
||||||
|
|
||||||
_ = dom.rebuild(&mut dioxus_core::NoOpMutations);
|
dom.rebuild(&mut dioxus_core::NoOpMutations);
|
||||||
|
|
||||||
for _ in 0..3 {
|
for _ in 0..3 {
|
||||||
dom.handle_event(
|
dom.handle_event(
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ fn app_drops() {
|
|||||||
|
|
||||||
let mut dom = VirtualDom::new(app);
|
let mut dom = VirtualDom::new(app);
|
||||||
|
|
||||||
_ = dom.rebuild(&mut dioxus_core::NoOpMutations);
|
dom.rebuild(&mut dioxus_core::NoOpMutations);
|
||||||
dom.mark_dirty(ScopeId::ROOT);
|
dom.mark_dirty(ScopeId::ROOT);
|
||||||
_ = dom.render_immediate_to_vec();
|
_ = dom.render_immediate_to_vec();
|
||||||
}
|
}
|
||||||
@@ -26,7 +26,7 @@ fn hooks_drop() {
|
|||||||
|
|
||||||
let mut dom = VirtualDom::new(app);
|
let mut dom = VirtualDom::new(app);
|
||||||
|
|
||||||
_ = dom.rebuild(&mut dioxus_core::NoOpMutations);
|
dom.rebuild(&mut dioxus_core::NoOpMutations);
|
||||||
dom.mark_dirty(ScopeId::ROOT);
|
dom.mark_dirty(ScopeId::ROOT);
|
||||||
_ = dom.render_immediate_to_vec();
|
_ = dom.render_immediate_to_vec();
|
||||||
}
|
}
|
||||||
@@ -49,7 +49,7 @@ fn contexts_drop() {
|
|||||||
|
|
||||||
let mut dom = VirtualDom::new(app);
|
let mut dom = VirtualDom::new(app);
|
||||||
|
|
||||||
_ = dom.rebuild(&mut dioxus_core::NoOpMutations);
|
dom.rebuild(&mut dioxus_core::NoOpMutations);
|
||||||
dom.mark_dirty(ScopeId::ROOT);
|
dom.mark_dirty(ScopeId::ROOT);
|
||||||
_ = dom.render_immediate_to_vec();
|
_ = dom.render_immediate_to_vec();
|
||||||
}
|
}
|
||||||
@@ -66,7 +66,7 @@ fn tasks_drop() {
|
|||||||
|
|
||||||
let mut dom = VirtualDom::new(app);
|
let mut dom = VirtualDom::new(app);
|
||||||
|
|
||||||
_ = dom.rebuild(&mut dioxus_core::NoOpMutations);
|
dom.rebuild(&mut dioxus_core::NoOpMutations);
|
||||||
dom.mark_dirty(ScopeId::ROOT);
|
dom.mark_dirty(ScopeId::ROOT);
|
||||||
_ = dom.render_immediate_to_vec();
|
_ = dom.render_immediate_to_vec();
|
||||||
}
|
}
|
||||||
@@ -81,7 +81,7 @@ fn root_props_drop() {
|
|||||||
RootProps("asdasd".to_string()),
|
RootProps("asdasd".to_string()),
|
||||||
);
|
);
|
||||||
|
|
||||||
_ = dom.rebuild(&mut dioxus_core::NoOpMutations);
|
dom.rebuild(&mut dioxus_core::NoOpMutations);
|
||||||
dom.mark_dirty(ScopeId::ROOT);
|
dom.mark_dirty(ScopeId::ROOT);
|
||||||
_ = dom.render_immediate_to_vec();
|
_ = dom.render_immediate_to_vec();
|
||||||
}
|
}
|
||||||
@@ -111,7 +111,7 @@ fn diffing_drops_old() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut dom = VirtualDom::new(app);
|
let mut dom = VirtualDom::new(app);
|
||||||
_ = dom.rebuild(&mut dioxus_core::NoOpMutations);
|
dom.rebuild(&mut dioxus_core::NoOpMutations);
|
||||||
dom.mark_dirty(ScopeId::ROOT);
|
dom.mark_dirty(ScopeId::ROOT);
|
||||||
|
|
||||||
_ = dom.render_immediate_to_vec();
|
_ = dom.render_immediate_to_vec();
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
use dioxus_core::NoOpMutations;
|
||||||
|
|
||||||
/// This test checks that we should release all memory used by the virtualdom when it exits.
|
/// This test checks that we should release all memory used by the virtualdom when it exits.
|
||||||
///
|
///
|
||||||
@@ -59,7 +60,7 @@ fn test_memory_leak() {
|
|||||||
|
|
||||||
let mut dom = VirtualDom::new(app);
|
let mut dom = VirtualDom::new(app);
|
||||||
|
|
||||||
_ = dom.rebuild(&mut dioxus_core::NoOpMutations);
|
dom.rebuild(&mut dioxus_core::NoOpMutations);
|
||||||
|
|
||||||
for _ in 0..5 {
|
for _ in 0..5 {
|
||||||
dom.mark_dirty(ScopeId::ROOT);
|
dom.mark_dirty(ScopeId::ROOT);
|
||||||
@@ -95,7 +96,7 @@ fn memo_works_properly() {
|
|||||||
|
|
||||||
let mut dom = VirtualDom::new(app);
|
let mut dom = VirtualDom::new(app);
|
||||||
|
|
||||||
_ = dom.rebuild(&mut dioxus_core::NoOpMutations);
|
dom.rebuild(&mut dioxus_core::NoOpMutations);
|
||||||
// todo!()
|
// todo!()
|
||||||
// dom.hard_diff(ScopeId::ROOT);
|
// dom.hard_diff(ScopeId::ROOT);
|
||||||
// dom.hard_diff(ScopeId::ROOT);
|
// dom.hard_diff(ScopeId::ROOT);
|
||||||
@@ -127,10 +128,10 @@ fn free_works_on_root_hooks() {
|
|||||||
|
|
||||||
let ptr = Rc::new("asdasd".to_string());
|
let ptr = Rc::new("asdasd".to_string());
|
||||||
let mut dom = VirtualDom::new_with_props(app, AppProps { inner: ptr.clone() });
|
let mut dom = VirtualDom::new_with_props(app, AppProps { inner: ptr.clone() });
|
||||||
let _ = dom.rebuild(&mut dioxus_core::NoOpMutations);
|
dom.rebuild(&mut dioxus_core::NoOpMutations);
|
||||||
|
|
||||||
// ptr gets cloned into props and then into the hook
|
// ptr gets cloned into props and then into the hook
|
||||||
assert_eq!(Rc::strong_count(&ptr), 4);
|
assert_eq!(Rc::strong_count(&ptr), 5);
|
||||||
|
|
||||||
drop(dom);
|
drop(dom);
|
||||||
|
|
||||||
@@ -148,21 +149,25 @@ fn supports_async() {
|
|||||||
|
|
||||||
use_hook(|| {
|
use_hook(|| {
|
||||||
spawn(async move {
|
spawn(async move {
|
||||||
sleep(Duration::from_millis(1000)).await;
|
loop {
|
||||||
colors.with_mut(|colors| colors.reverse());
|
sleep(Duration::from_millis(1000)).await;
|
||||||
|
colors.with_mut(|colors| colors.reverse());
|
||||||
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
use_hook(|| {
|
use_hook(|| {
|
||||||
spawn(async move {
|
spawn(async move {
|
||||||
sleep(Duration::from_millis(10)).await;
|
loop {
|
||||||
padding.with_mut(|padding| {
|
sleep(Duration::from_millis(10)).await;
|
||||||
if *padding < 65 {
|
padding.with_mut(|padding| {
|
||||||
*padding += 1;
|
if *padding < 65 {
|
||||||
} else {
|
*padding += 1;
|
||||||
*padding = 5;
|
} else {
|
||||||
}
|
*padding = 5;
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -189,11 +194,11 @@ fn supports_async() {
|
|||||||
|
|
||||||
rt.block_on(async {
|
rt.block_on(async {
|
||||||
let mut dom = VirtualDom::new(app);
|
let mut dom = VirtualDom::new(app);
|
||||||
let _ = dom.rebuild(&mut dioxus_core::NoOpMutations);
|
dom.rebuild(&mut dioxus_core::NoOpMutations);
|
||||||
|
|
||||||
for _ in 0..10 {
|
for _ in 0..10 {
|
||||||
dom.wait_for_work().await;
|
dom.wait_for_work().await;
|
||||||
let _edits = dom.render_immediate_to_vec();
|
dom.render_immediate(&mut NoOpMutations);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn it_works() {
|
fn suspense_resolves() {
|
||||||
// wait just a moment, not enough time for the boundary to resolve
|
// wait just a moment, not enough time for the boundary to resolve
|
||||||
|
|
||||||
tokio::runtime::Builder::new_current_thread()
|
tokio::runtime::Builder::new_current_thread()
|
||||||
@@ -9,7 +9,7 @@ fn it_works() {
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
.block_on(async {
|
.block_on(async {
|
||||||
let mut dom = VirtualDom::new(app);
|
let mut dom = VirtualDom::new(app);
|
||||||
_ = dom.rebuild(&mut dioxus_core::NoOpMutations);
|
dom.rebuild(&mut dioxus_core::NoOpMutations);
|
||||||
dom.wait_for_suspense().await;
|
dom.wait_for_suspense().await;
|
||||||
let out = dioxus_ssr::render(&dom);
|
let out = dioxus_ssr::render(&dom);
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ async fn it_works() {
|
|||||||
|
|
||||||
let mut dom = VirtualDom::new(app);
|
let mut dom = VirtualDom::new(app);
|
||||||
|
|
||||||
let _ = dom.rebuild(&mut dioxus_core::NoOpMutations);
|
dom.rebuild(&mut dioxus_core::NoOpMutations);
|
||||||
|
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
_ = dom.wait_for_work() => {}
|
_ = dom.wait_for_work() => {}
|
||||||
|
|||||||
+126
-127
@@ -80,146 +80,145 @@ impl Renderer {
|
|||||||
})
|
})
|
||||||
.clone();
|
.clone();
|
||||||
|
|
||||||
// let mut inner_html = None;
|
let mut inner_html = None;
|
||||||
|
|
||||||
// // We need to keep track of the dynamic styles so we can insert them into the right place
|
// We need to keep track of the dynamic styles so we can insert them into the right place
|
||||||
// let mut accumulated_dynamic_styles = Vec::new();
|
let mut accumulated_dynamic_styles = Vec::new();
|
||||||
|
|
||||||
// // We need to keep track of the listeners so we can insert them into the right place
|
// We need to keep track of the listeners so we can insert them into the right place
|
||||||
// let mut accumulated_listeners = Vec::new();
|
let mut accumulated_listeners = Vec::new();
|
||||||
|
|
||||||
// for segment in entry.segments.iter() {
|
for segment in entry.segments.iter() {
|
||||||
// match segment {
|
match segment {
|
||||||
// Segment::Attr(idx) => {
|
Segment::Attr(idx) => {
|
||||||
// let attr = &template.dynamic_attrs[*idx];
|
let attrs = &*template.dynamic_attrs[*idx];
|
||||||
// attr.attribute_type().try_for_each(|attr| {
|
for attr in attrs {
|
||||||
// if attr.name == "dangerous_inner_html" {
|
if attr.name == "dangerous_inner_html" {
|
||||||
// inner_html = Some(attr);
|
inner_html = Some(attr);
|
||||||
// } else if attr.namespace == Some("style") {
|
} else if attr.namespace == Some("style") {
|
||||||
// accumulated_dynamic_styles.push(attr);
|
accumulated_dynamic_styles.push(attr);
|
||||||
// } else if BOOL_ATTRS.contains(&attr.name) {
|
} else if BOOL_ATTRS.contains(&attr.name) {
|
||||||
// if truthy(&attr.value) {
|
if truthy(&attr.value) {
|
||||||
// write_attribute(buf, attr)?;
|
write_attribute(buf, attr)?;
|
||||||
// }
|
}
|
||||||
// } else {
|
} else {
|
||||||
// write_attribute(buf, attr)?;
|
write_attribute(buf, attr)?;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if self.pre_render {
|
if self.pre_render {
|
||||||
// if let AttributeValue::Listener(_) = &attr.value {
|
if let AttributeValue::Listener(_) = &attr.value {
|
||||||
// // The onmounted event doesn't need a DOM listener
|
// The onmounted event doesn't need a DOM listener
|
||||||
// if attr.name != "onmounted" {
|
if attr.name != "onmounted" {
|
||||||
// accumulated_listeners.push(attr.name);
|
accumulated_listeners.push(attr.name);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// Ok(())
|
}
|
||||||
// })?;
|
}
|
||||||
// }
|
Segment::Node(idx) => match &template.dynamic_nodes[*idx] {
|
||||||
// Segment::Node(idx) => match &template.dynamic_nodes[*idx] {
|
DynamicNode::Component(node) => {
|
||||||
// DynamicNode::Component(node) => {
|
if self.skip_components {
|
||||||
// if self.skip_components {
|
write!(buf, "<{}><{}/>", node.name, node.name)?;
|
||||||
// write!(buf, "<{}><{}/>", node.name, node.name)?;
|
} else {
|
||||||
// } else {
|
let scope = node.mounted_scope(*idx, template, dom).unwrap();
|
||||||
// let scope = node.mounted_scope(*idx, template, dom).unwrap();
|
let node = scope.root_node();
|
||||||
// let node = scope.root_node();
|
match node {
|
||||||
// match node {
|
RenderReturn::Ready(node) => {
|
||||||
// RenderReturn::Ready(node) => {
|
self.render_template(buf, dom, node)?
|
||||||
// self.render_template(buf, dom, node)?
|
}
|
||||||
// }
|
_ => todo!(
|
||||||
// _ => todo!(
|
"generally, scopes should be sync, only if being traversed"
|
||||||
// "generally, scopes should be sync, only if being traversed"
|
),
|
||||||
// ),
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
DynamicNode::Text(text) => {
|
||||||
// DynamicNode::Text(text) => {
|
// in SSR, we are concerned that we can't hunt down the right text node since they might get merged
|
||||||
// // in SSR, we are concerned that we can't hunt down the right text node since they might get merged
|
if self.pre_render {
|
||||||
// if self.pre_render {
|
write!(buf, "<!--node-id{}-->", self.dynamic_node_id)?;
|
||||||
// write!(buf, "<!--node-id{}-->", self.dynamic_node_id)?;
|
self.dynamic_node_id += 1;
|
||||||
// self.dynamic_node_id += 1;
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
// write!(
|
write!(
|
||||||
// buf,
|
buf,
|
||||||
// "{}",
|
"{}",
|
||||||
// askama_escape::escape(&text.value, askama_escape::Html)
|
askama_escape::escape(&text.value, askama_escape::Html)
|
||||||
// )?;
|
)?;
|
||||||
|
|
||||||
// if self.pre_render {
|
if self.pre_render {
|
||||||
// write!(buf, "<!--#-->")?;
|
write!(buf, "<!--#-->")?;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// DynamicNode::Fragment(nodes) => {
|
DynamicNode::Fragment(nodes) => {
|
||||||
// for child in nodes {
|
for child in nodes {
|
||||||
// self.render_template(buf, dom, child)?;
|
self.render_template(buf, dom, child)?;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// DynamicNode::Placeholder(_) => {
|
DynamicNode::Placeholder(_) => {
|
||||||
// if self.pre_render {
|
if self.pre_render {
|
||||||
// write!(
|
write!(
|
||||||
// buf,
|
buf,
|
||||||
// "<pre data-node-hydration={}></pre>",
|
"<pre data-node-hydration={}></pre>",
|
||||||
// self.dynamic_node_id
|
self.dynamic_node_id
|
||||||
// )?;
|
)?;
|
||||||
// self.dynamic_node_id += 1;
|
self.dynamic_node_id += 1;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// },
|
},
|
||||||
|
|
||||||
// Segment::PreRendered(contents) => write!(buf, "{contents}")?,
|
Segment::PreRendered(contents) => write!(buf, "{contents}")?,
|
||||||
|
|
||||||
// Segment::StyleMarker { inside_style_tag } => {
|
Segment::StyleMarker { inside_style_tag } => {
|
||||||
// if !accumulated_dynamic_styles.is_empty() {
|
if !accumulated_dynamic_styles.is_empty() {
|
||||||
// // if we are inside a style tag, we don't need to write the style attribute
|
// if we are inside a style tag, we don't need to write the style attribute
|
||||||
// if !*inside_style_tag {
|
if !*inside_style_tag {
|
||||||
// write!(buf, " style=\"")?;
|
write!(buf, " style=\"")?;
|
||||||
// }
|
}
|
||||||
// for attr in &accumulated_dynamic_styles {
|
for attr in &accumulated_dynamic_styles {
|
||||||
// write!(buf, "{}:", attr.name)?;
|
write!(buf, "{}:", attr.name)?;
|
||||||
// write_value_unquoted(buf, &attr.value)?;
|
write_value_unquoted(buf, &attr.value)?;
|
||||||
// write!(buf, ";")?;
|
write!(buf, ";")?;
|
||||||
// }
|
}
|
||||||
// if !*inside_style_tag {
|
if !*inside_style_tag {
|
||||||
// write!(buf, "\"")?;
|
write!(buf, "\"")?;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// // clear the accumulated styles
|
// clear the accumulated styles
|
||||||
// accumulated_dynamic_styles.clear();
|
accumulated_dynamic_styles.clear();
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// Segment::InnerHtmlMarker => {
|
Segment::InnerHtmlMarker => {
|
||||||
// if let Some(inner_html) = inner_html.take() {
|
if let Some(inner_html) = inner_html.take() {
|
||||||
// let inner_html = &inner_html.value;
|
let inner_html = &inner_html.value;
|
||||||
// match inner_html {
|
match inner_html {
|
||||||
// AttributeValue::Text(value) => write!(buf, "{}", value)?,
|
AttributeValue::Text(value) => write!(buf, "{}", value)?,
|
||||||
// AttributeValue::Bool(value) => write!(buf, "{}", value)?,
|
AttributeValue::Bool(value) => write!(buf, "{}", value)?,
|
||||||
// AttributeValue::Float(f) => write!(buf, "{}", f)?,
|
AttributeValue::Float(f) => write!(buf, "{}", f)?,
|
||||||
// AttributeValue::Int(i) => write!(buf, "{}", i)?,
|
AttributeValue::Int(i) => write!(buf, "{}", i)?,
|
||||||
// _ => {}
|
_ => {}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// Segment::AttributeNodeMarker => {
|
Segment::AttributeNodeMarker => {
|
||||||
// // first write the id
|
// first write the id
|
||||||
// write!(buf, "{}", self.dynamic_node_id)?;
|
write!(buf, "{}", self.dynamic_node_id)?;
|
||||||
// self.dynamic_node_id += 1;
|
self.dynamic_node_id += 1;
|
||||||
// // then write any listeners
|
// then write any listeners
|
||||||
// for name in accumulated_listeners.drain(..) {
|
for name in accumulated_listeners.drain(..) {
|
||||||
// write!(buf, ",{}:", &name[2..])?;
|
write!(buf, ",{}:", &name[2..])?;
|
||||||
// write!(buf, "{}", dioxus_html::event_bubbles(name) as u8)?;
|
write!(buf, "{}", dioxus_html::event_bubbles(name) as u8)?;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// Segment::RootNodeMarker => {
|
Segment::RootNodeMarker => {
|
||||||
// write!(buf, "{}", self.dynamic_node_id)?;
|
write!(buf, "{}", self.dynamic_node_id)?;
|
||||||
// self.dynamic_node_id += 1
|
self.dynamic_node_id += 1
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user