@@ -71,11 +71,16 @@ function parseAttribute(name: string, value: string, parentElement: XmlElement,
7171 options : IOptions ) : void
7272{
7373 let attribute = parentElement . attribute ( name , "" ) ;
74- if ( ! isType ( value , "String" ) ) {
75- throw new Error ( "attribute value for name '" + name + "' should be a" +
76- " string" ) ;
74+ if ( isType ( value , "String" ) || isType ( value , "Number" )
75+ || isType ( value , "Boolean" ) || isType ( value , "Undefined" )
76+ || isType ( value , "Null" ) )
77+ {
78+ parseString ( stringify ( value ) , attribute , options ) ;
79+ } else {
80+ throw new Error ( "attribute value for name '" + name + "' should be a"
81+ + " primitive (string, number, boolean, null, or"
82+ + " undefined)" ) ;
7783 }
78- parseString ( value , attribute , options ) ;
7984}
8085
8186/**
@@ -127,8 +132,8 @@ function parseObjectOrMapEntry(key: string, value: any,
127132 parseValue ( key , value , parentElement , options ) ;
128133 return ;
129134 } else {
130- throw new Error ( "value value " + value + " must be a primitive"
131- + " (string, number, null, or undefined)" ) ;
135+ throw new Error ( "value " + value + " should be a primitive"
136+ + " (string, number, boolean, null, or undefined)" ) ;
132137 }
133138 }
134139
0 commit comments