@@ -414,4 +414,46 @@ describe("XMLParser StopNodes", function () {
414
414
// console.log(JSON.stringify(jObj, null, 4));
415
415
expect ( jObj ) . toEqual ( expected ) ;
416
416
} ) ;
417
+ it ( "should parse attributes correctly for self closing stop node" , function ( ) {
418
+
419
+ const xmlData = `<script/>` ;
420
+ const options = {
421
+ allowBooleanAttributes : true ,
422
+ ignoreAttributes : false ,
423
+ stopNodes : [ "*.pre" , "*.script" ] ,
424
+ } ;
425
+ const expected = {
426
+ "script" : ""
427
+ }
428
+ const parser = new XMLParser ( options ) ;
429
+ // console.log(JSON.stringify(parser.parse(xml)));
430
+
431
+ let result = parser . parse ( xmlData ) ;
432
+
433
+ // console.log(JSON.stringify(result,null,4));
434
+ expect ( result ) . toEqual ( expected ) ;
435
+
436
+ } ) ;
437
+ it ( "should parse attributes correctly for self closing stop node" , function ( ) {
438
+
439
+ const xmlData = `<script src="some.js" />` ;
440
+ const options = {
441
+ allowBooleanAttributes : true ,
442
+ ignoreAttributes : false ,
443
+ stopNodes : [ "*.pre" , "*.script" ] ,
444
+ } ;
445
+ const expected = {
446
+ "script" : {
447
+ "@_src" : "some.js"
448
+ }
449
+ }
450
+ const parser = new XMLParser ( options ) ;
451
+ // console.log(JSON.stringify(parser.parse(xml)));
452
+
453
+ let result = parser . parse ( xmlData ) ;
454
+
455
+ // console.log(JSON.stringify(result,null,4));
456
+ expect ( result ) . toEqual ( expected ) ;
457
+
458
+ } ) ;
417
459
} ) ;
0 commit comments