@@ -33,8 +33,8 @@ function parseString(str: string, parentElement: XmlAttribute | XmlElement,
3333 options : IOptions ) : void
3434{
3535 let requiresCdata = ( s : string ) => {
36- return ( options . cdata && ( s . indexOf ( "<" ) !== - 1
37- || s . indexOf ( "&" ) !== - 1 ) )
36+ return ( options . cdataInvalidChars && ( s . indexOf ( "<" ) !== - 1
37+ || s . indexOf ( "&" ) !== - 1 ) )
3838 || options . cdataKeys . indexOf ( parentElement . name ) !== - 1
3939 || options . cdataKeys . indexOf ( "*" ) !== - 1 ;
4040 } ;
@@ -96,16 +96,17 @@ function parseObjectOrMapEntry(key: string, value: any,
9696 options : IOptions ) : void
9797{
9898 // Alias key
99- if ( key === options . alias ) {
99+ if ( key === options . aliasString ) {
100100 if ( ! isType ( value , "String" ) ) {
101- throw new Error ( "alias value for " + value + " should be a string" ) ;
101+ throw new Error ( "aliasString value for " + value
102+ + " should be a string" ) ;
102103 }
103104 parentElement . name = value ;
104105 return ;
105106 }
106107
107108 // Attributes key
108- if ( key . indexOf ( options . attrPrefix ) === 0 ) {
109+ if ( key . indexOf ( options . attributeString ) === 0 ) {
109110 if ( isType ( value , "Object" ) ) {
110111 for ( let subkey of Object . keys ( value ) ) {
111112 parseAttribute ( subkey , value [ subkey ] , parentElement , options ) ;
@@ -118,7 +119,7 @@ function parseObjectOrMapEntry(key: string, value: any,
118119 }
119120
120121 // Value key
121- if ( key . indexOf ( options . valPrefix ) === 0 ) {
122+ if ( key . indexOf ( options . valueString ) === 0 ) {
122123 if ( isType ( value , "String" ) || isType ( value , "Number" )
123124 || isType ( value , "Boolean" ) || isType ( value , "Null" )
124125 || isType ( value , "Undefined" ) )
@@ -182,11 +183,11 @@ function parseArrayOrSet(key: string, arrayOrSet: any,
182183 parentElement : XmlElement , options : IOptions ) : void
183184{
184185 let arrayNameFunc : ( key : string , value : any ) => string ;
185- if ( options . arraySetWrapHandlers . hasOwnProperty ( "*" ) ) {
186- arrayNameFunc = options . arraySetWrapHandlers [ "*" ] ;
186+ if ( options . wrapHandlers . hasOwnProperty ( "*" ) ) {
187+ arrayNameFunc = options . wrapHandlers [ "*" ] ;
187188 }
188- if ( options . arraySetWrapHandlers . hasOwnProperty ( key ) ) {
189- arrayNameFunc = options . arraySetWrapHandlers [ key ] ;
189+ if ( options . wrapHandlers . hasOwnProperty ( key ) ) {
190+ arrayNameFunc = options . wrapHandlers [ key ] ;
190191 }
191192
192193 let arrayKey = key ;
@@ -197,7 +198,7 @@ function parseArrayOrSet(key: string, arrayOrSet: any,
197198 arrayKey = arrayNameFuncKey ;
198199 arrayElement = parentElement . element ( key ) ;
199200 } else if ( ! isType ( arrayNameFuncKey , "Null" ) ) {
200- throw new Error ( "arraySetWrapHandlers function for " + arrayKey
201+ throw new Error ( "wrapHandlers function for " + arrayKey
201202 + " should return a string or null" ) ;
202203 }
203204 }
@@ -269,8 +270,8 @@ function parseToDocument(root: string, value: any,
269270 options : IOptions ) : XmlDocument
270271{
271272 let document : XmlDocument = new XmlDocument ( root ) ;
272- if ( options . decl . include ) {
273- document . decl ( options . decl ) ;
273+ if ( options . declaration . include ) {
274+ document . decl ( options . declaration ) ;
274275 }
275276 if ( options . dtd . include ) {
276277 document . dtd ( options . dtd . name , options . dtd . sysId , options . dtd . pubId ) ;
@@ -282,18 +283,17 @@ function parseToDocument(root: string, value: any,
282283/**
283284 * Returns a XML string representation of the specified object.
284285 *
285- * @param {string } root The name of the root XML element. When the object
286- * is converted to XML, it will be a child of this
287- * root element.
286+ * @param {string } root The name of the root XML element. When the
287+ * object is converted to XML, it will be a
288+ * child of this root element.
288289 * @param {* } object The object to convert to XML.
289- * @param {IOptions } [options] Options for parsing the object and formatting the
290- * resulting XML.
290+ * @param {IOptions } [options] Options for parsing the object and
291+ * formatting the resulting XML.
291292 *
292293 * @returns {string } An XML string representation of the specified object.
293294 */
294295export function parse ( root : string , object : any ,
295- options : IOptions = { } ) : string
296- {
296+ options : IOptions = { } ) : string {
297297 options = validateOptions ( options ) ;
298298 let document = parseToDocument ( root , object , options ) ;
299299 return document . toString ( options . format ) ;
0 commit comments