@@ -36,11 +36,11 @@ export class XmlSerializer extends XmlBaseSerializer {
36
36
}
37
37
38
38
#buildXmlDocument (
39
- normalizedBom : SimpleXml . Element
39
+ rootElement : SimpleXml . Element
40
40
) : XMLDocument {
41
41
const namespace = null
42
42
const doc = document . implementation . createDocument ( namespace , null )
43
- doc . appendChild ( this . #buildElement( normalizedBom , doc , namespace ) )
43
+ doc . appendChild ( this . #buildElement( rootElement , doc , namespace ) )
44
44
return doc
45
45
}
46
46
@@ -58,7 +58,7 @@ export class XmlSerializer extends XmlBaseSerializer {
58
58
this . #setAttributes( node , element . attributes )
59
59
}
60
60
if ( isNotUndefined ( element . children ) ) {
61
- this . #setChildren ( node , element . children , ns )
61
+ this . #addChildren ( node , element . children , ns )
62
62
}
63
63
return node
64
64
}
@@ -72,14 +72,18 @@ export class XmlSerializer extends XmlBaseSerializer {
72
72
}
73
73
}
74
74
75
- #setChildren ( node : Element , children : SimpleXml . ElementChildren , parentNS : string | null = null ) : void {
75
+ #addChildren ( node : Element , children : SimpleXml . ElementChildren , parentNS : string | null = null ) : void {
76
+ if ( children === undefined ) {
77
+ return
78
+ }
79
+
76
80
if ( typeof children === 'string' || typeof children === 'number' ) {
77
81
node . textContent = children . toString ( )
78
82
return
79
83
}
80
84
81
85
const doc = node . ownerDocument
82
- for ( const child of ( children as Iterable < SimpleXml . Comment | SimpleXml . Element > ) ) {
86
+ for ( const child of children ) {
83
87
if ( child . type === 'element' ) {
84
88
node . appendChild ( this . #buildElement( child , doc , parentNS ) )
85
89
}
0 commit comments