fix templates being registered in mutations many times (#722)
This commit is contained in:
1 parent
64881fd951
commit
a616a8fa9d
1 file changed
+8
-4
@@ -81,9 +81,7 @@ impl<'b> VirtualDom {
|
||||
|
||||
// The best renderers will have templates prehydrated and registered
|
||||
// Just in case, let's create the template using instructions anyways
|
||||
if !self.templates.contains_key(&node.template.get().name) {
|
||||
self.register_template(node.template.get());
|
||||
}
|
||||
|
||||
// we know that this will generate at least one mutation per node
|
||||
self.mutations
|
||||
@@ -389,10 +387,15 @@ impl<'b> VirtualDom {
|
||||
|
||||
/// Insert a new template into the VirtualDom's template registry
|
||||
pub(crate) fn register_template(&mut self, mut template: Template<'static>) {
|
||||
// First, make sure we mark the template as seen, regardless if we process it
|
||||
let (path, byte_index) = template.name.rsplit_once(':').unwrap();
|
||||
let byte_index = byte_index.parse::<usize>().unwrap();
|
||||
|
||||
// First, check if we've already seen this template
|
||||
if self
|
||||
.templates
|
||||
.get(&path)
|
||||
.filter(|set| set.contains_key(&byte_index))
|
||||
.is_none()
|
||||
{
|
||||
// if hot reloading is enabled, then we need to check for a template that has overriten this one
|
||||
#[cfg(debug_assertions)]
|
||||
if let Some(mut new_template) = self
|
||||
@@ -415,6 +418,7 @@ impl<'b> VirtualDom {
|
||||
self.mutations.templates.push(template);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn create_dynamic_node(
|
||||
&mut self,
|
||||
|
||||
Reference in new issue
Block a user