diff --git a/crates/obscura-dom/src/serialize.rs b/crates/obscura-dom/src/serialize.rs index 3850945..8cb2abf 100644 --- a/crates/obscura-dom/src/serialize.rs +++ b/crates/obscura-dom/src/serialize.rs @@ -30,10 +30,12 @@ impl DomTree { // there rather than under the element (issue #463); for everything else it // is the node itself. fn content_source(&self, node_id: NodeId) -> NodeId { - match self.get_node(node_id).map(|n| n.data) { - Some(NodeData::Element { template_contents: Some(contents), .. }) => contents, - _ => node_id, - } + self.with_node(node_id, |n| match &n.data { + NodeData::Element { template_contents: Some(contents), .. } => Some(*contents), + _ => None, + }) + .flatten() + .unwrap_or(node_id) } // Children as work items in document order (top of the LIFO stack first). @@ -90,7 +92,7 @@ impl DomTree { buf.push_str(name); buf.push('>'); } - NodeData::Element { name, attrs, .. } => { + NodeData::Element { name, attrs, template_contents, .. } => { let tag = name.local.as_ref(); if include_self { buf.push('<'); @@ -113,8 +115,11 @@ impl DomTree { stack.push(SerializeWork::CloseTag(tag.to_string())); } // A