@@ -52,7 +52,7 @@ enum NodeEnum {
5252 Data ( DataType , StrTendril ) ,
5353 Doctype ( StrTendril , StrTendril , StrTendril ) ,
5454 Document ,
55- Element ( QualName , Vec < Attribute > ) ,
55+ Element ( QualName , Vec < Attribute > , bool ) ,
5656 ProcessingInstruction ( StrTendril , StrTendril ) ,
5757 Text ( StrTendril ) ,
5858}
@@ -201,9 +201,13 @@ impl TreeSink for FlatDom {
201201 Id ( 0 )
202202 }
203203
204- // Not supported
205- fn get_template_contents ( & mut self , _target : & Self :: Handle ) -> Self :: Handle {
206- panic ! ( "Templates not supported" ) ;
204+ fn get_template_contents ( & mut self , target : & Self :: Handle ) -> Self :: Handle {
205+ if let Element ( _, _, true ) = self . node ( * target) . node {
206+ // Use template element as document fragment
207+ target. clone ( )
208+ } else {
209+ panic ! ( "not a template element!" )
210+ }
207211 }
208212
209213 // Not supported
@@ -221,8 +225,8 @@ impl TreeSink for FlatDom {
221225 }
222226 }
223227
224- fn create_element ( & mut self , name : QualName , attrs : Vec < Attribute > , _flags : ElementFlags ) -> Self :: Handle {
225- self . add_node ( Element ( name, attrs) )
228+ fn create_element ( & mut self , name : QualName , attrs : Vec < Attribute > , flags : ElementFlags ) -> Self :: Handle {
229+ self . add_node ( Element ( name, attrs, flags . template ) )
226230 }
227231
228232 fn create_comment ( & mut self , text : StrTendril ) -> Self :: Handle {
@@ -479,7 +483,7 @@ impl NifEncoder for Node {
479483
480484 Document => unreachable ! ( ) ,
481485
482- Element ( ref name, ref attributes) => {
486+ Element ( ref name, ref attributes, ref _template ) => {
483487 let namespace_atom = atoms:: namespace ( ) . encode ( env) ;
484488 let tag_atom = atoms:: tag ( ) . encode ( env) ;
485489 let attributes_atom = atoms:: attributes ( ) . encode ( env) ;
0 commit comments