@@ -27,7 +27,7 @@ export class XMLBuilderImpl implements XMLBuilder {
2727
2828 /**
2929 * Initializes a new instance of `XMLBuilderNodeImpl`.
30- *
30+ *
3131 * @param domNode - the DOM node to wrap
3232 */
3333 constructor ( domNode : Node ) {
@@ -53,19 +53,19 @@ export class XMLBuilderImpl implements XMLBuilder {
5353 p3 ?: AttributesObject ) : XMLBuilder {
5454
5555 let namespace : string | null | undefined
56- let name : string | ExpandObject | undefined
56+ let name : string | ExpandObject | undefined | null
5757 let attributes : AttributesObject | undefined
5858
59- if ( isObject ( p1 ) ) {
59+ if ( isObject < string > ( p1 ) ) {
6060 // ele(obj: ExpandObject)
6161 return new ObjectReader ( this . _options ) . parse ( this , p1 )
62- } else if ( p1 !== null && / ^ \s * < / . test ( p1 ) ) {
62+ } else if ( isString ( p1 ) && p1 !== null && / ^ \s * < / . test ( p1 ) ) {
6363 // parse XML document string
6464 return new XMLReader ( this . _options ) . parse ( this , p1 )
65- } else if ( p1 !== null && / ^ \s * [ \{ \[ ] / . test ( p1 ) ) {
65+ } else if ( isString ( p1 ) && p1 !== null && / ^ \s * [ \{ \[ ] / . test ( p1 ) ) {
6666 // parse JSON string
6767 return new JSONReader ( this . _options ) . parse ( this , p1 )
68- } else if ( p1 !== null && / ^ ( \s * | ( # .* ) | ( % .* ) ) * - - - / . test ( p1 ) ) {
68+ } else if ( isString ( p1 ) && p1 !== null && / ^ ( \s * | ( # .* ) | ( % .* ) ) * - - - / . test ( p1 ) ) {
6969 // parse YAML string
7070 return new YAMLReader ( this . _options ) . parse ( this , p1 )
7171 }
@@ -86,7 +86,7 @@ export class XMLBuilderImpl implements XMLBuilder {
8686
8787 [ namespace , name ] = this . _extractNamespace (
8888 sanitizeInput ( namespace , this . _options . invalidCharReplacement ) ,
89- sanitizeInput ( name , this . _options . invalidCharReplacement ) , true )
89+ sanitizeInput ( name as string , this . _options . invalidCharReplacement ) , true )
9090
9191 // inherit namespace from parent
9292 if ( namespace === undefined ) {
@@ -130,7 +130,7 @@ export class XMLBuilderImpl implements XMLBuilder {
130130 /** @inheritdoc */
131131 att ( p1 : AttributesObject | string | null , p2 ?: string , p3 ?: string ) : XMLBuilder {
132132
133- if ( isMap ( p1 ) || isObject ( p1 ) ) {
133+ if ( isMap < string > ( p1 ) || isObject < string > ( p1 ) ) {
134134 // att(obj: AttributesObject)
135135 // expand if object
136136 forEachObject ( p1 , ( attName , attValue ) => this . att ( attName , attValue ) , this )
@@ -228,7 +228,7 @@ export class XMLBuilderImpl implements XMLBuilder {
228228 throw new Error ( "Attribute namespace must be a string. " + this . _debugInfo ( ) )
229229 }
230230
231- if ( isArray ( name ) || isSet ( name ) ) {
231+ if ( isArray < string > ( name ) || isSet < string > ( name ) ) {
232232 // removeAtt(names: string[])
233233 // removeAtt(namespace: string, names: string[])
234234 forEachArray ( name , attName =>
@@ -316,15 +316,15 @@ export class XMLBuilderImpl implements XMLBuilder {
316316 }
317317 }
318318
319- if ( isArray ( target ) || isSet ( target ) ) {
320- forEachArray ( target , item => {
319+ if ( isArray < string > ( target ) || isSet < string > ( target ) ) {
320+ forEachArray < string > ( target , item => {
321321 item += ""
322322 const insIndex = item . indexOf ( ' ' )
323323 const insTarget = ( insIndex === - 1 ? item : item . substr ( 0 , insIndex ) )
324324 const insValue = ( insIndex === - 1 ? '' : item . substr ( insIndex + 1 ) )
325325 this . ins ( insTarget , insValue )
326326 } , this )
327- } else if ( isMap ( target ) || isObject ( target ) ) {
327+ } else if ( isMap < string > ( target ) || isObject < string > ( target ) ) {
328328 forEachObject ( target , ( insTarget , insValue ) => this . ins ( insTarget , insValue ) , this )
329329 } else {
330330 const child = this . _doc . createProcessingInstruction (
@@ -619,7 +619,7 @@ export class XMLBuilderImpl implements XMLBuilder {
619619 * Gets the next descendant of the given node of the tree rooted at `root`
620620 * in depth-first pre-order. Returns a three-tuple with
621621 * [descendant, descendant_index, descendant_level].
622- *
622+ *
623623 * @param root - root node of the tree
624624 * @param self - whether to visit the current node along with child nodes
625625 * @param recursive - whether to visit all descendant nodes in tree-order or
@@ -638,7 +638,7 @@ export class XMLBuilderImpl implements XMLBuilder {
638638 * Gets the next descendant of the given node of the tree rooted at `root`
639639 * in depth-first pre-order. Returns a three-tuple with
640640 * [descendant, descendant_index, descendant_level].
641- *
641+ *
642642 * @param root - root node of the tree
643643 * @param node - current node
644644 * @param recursive - whether to visit all descendant nodes in tree-order or
@@ -675,7 +675,7 @@ export class XMLBuilderImpl implements XMLBuilder {
675675
676676 /**
677677 * Converts the node into its string or object representation.
678- *
678+ *
679679 * @param options - serialization options
680680 */
681681 private _serialize ( writerOptions : WriterOptions ) : XMLSerializedValue {
@@ -701,7 +701,7 @@ export class XMLBuilderImpl implements XMLBuilder {
701701
702702 /**
703703 * Extracts a namespace and name from the given string.
704- *
704+ *
705705 * @param namespace - namespace
706706 * @param name - a string containing both a name and namespace separated by an
707707 * `'@'` character
@@ -732,7 +732,7 @@ export class XMLBuilderImpl implements XMLBuilder {
732732
733733 /**
734734 * Updates the element's namespace.
735- *
735+ *
736736 * @param ns - new namespace
737737 */
738738 private _updateNamespace ( ns : string | null ) : void {
@@ -797,7 +797,7 @@ export class XMLBuilderImpl implements XMLBuilder {
797797
798798 /**
799799 * Returns debug information for this node.
800- *
800+ *
801801 * @param name - node name
802802 */
803803 protected _debugInfo ( name ?: string ) : string {
0 commit comments