wip: clean up some things

This commit is contained in:
Jonathan Kelley committed 2022-11-30 23:54:30 -05:00
1 parent ba26b1001a
commit 3b166c9edd
64 files changed
+540 -599

No files matched your search

+23 -23
View File
@@ -228,27 +228,29 @@ impl<'b> VirtualDom {
self.create_static_node(node);
}
self.mutations.template_mutations.push(SaveTemplate {
self.mutations.template_edits.push(SaveTemplate {
name: template.template.id,
m: template.template.roots.len(),
});
}
// todo: we shouldn't have any of instructions for building templates - renderers should be able to work with the
// template type directly, right?
pub(crate) fn create_static_node(&mut self, node: &'b TemplateNode<'static>) {
match *node {
// Todo: create the children's template
TemplateNode::Dynamic(_) => self
.mutations
.template_mutations
.template_edits
.push(CreateStaticPlaceholder {}),
TemplateNode::Text(value) => self
.mutations
.template_mutations
.template_edits
.push(CreateStaticText { value }),
TemplateNode::DynamicText { .. } => self
.mutations
.template_mutations
.push(CreateTextPlaceholder),
TemplateNode::DynamicText { .. } => {
self.mutations.template_edits.push(CreateTextPlaceholder)
}
TemplateNode::Element {
attrs,
@@ -257,21 +259,19 @@ impl<'b> VirtualDom {
tag,
..
} => {
if let Some(namespace) = namespace {
self.mutations
.template_mutations
.push(CreateElementNamespace {
name: tag,
namespace,
});
} else {
self.mutations
.template_mutations
.push(CreateElement { name: tag });
match namespace {
Some(namespace) => self.mutations.template_edits.push(CreateElementNamespace {
name: tag,
namespace,
}),
None => self
.mutations
.template_edits
.push(CreateElement { name: tag }),
}
self.mutations
.template_mutations
.template_edits
.extend(attrs.iter().filter_map(|attr| match attr {
TemplateAttribute::Static {
name,
@@ -295,7 +295,7 @@ impl<'b> VirtualDom {
.for_each(|child| self.create_static_node(child));
self.mutations
.template_mutations
.template_edits
.push(AppendChildren { m: children.len() })
}
}
@@ -404,7 +404,7 @@ impl<'b> VirtualDom {
) -> usize {
// Keep track of how many mutations are in the buffer in case we need to split them out if a suspense boundary
// is encountered
let mutations_to_this_point = self.mutations.len();
let mutations_to_this_point = self.mutations.dom_edits.len();
// Create the component's root element
let created = self.create_scope(scope, new);
@@ -430,10 +430,10 @@ impl<'b> VirtualDom {
// Note that we break off dynamic mutations only - since static mutations aren't rendered immediately
let split_off = unsafe {
std::mem::transmute::<Vec<Mutation>, Vec<Mutation>>(
self.mutations.split_off(mutations_to_this_point),
self.mutations.dom_edits.split_off(mutations_to_this_point),
)
};
boundary.mutations.borrow_mut().edits.extend(split_off);
boundary.mutations.borrow_mut().dom_edits.extend(split_off);
boundary.created_on_stack.set(created);
boundary
.waiting_on