@@ -193,9 +193,9 @@ function resolveNameSpace(tagname) {
193193//const attrsRegx = new RegExp("([\\w\\-\\.\\:]+)\\s*=\\s*(['\"])((.|\n)*?)\\2","gm");
194194const attrsRegx = new RegExp ( '([^\\s=]+)\\s*(=\\s*([\'"])([\\s\\S]*?)\\3)?' , 'gm' ) ;
195195
196- function buildAttributesMap ( attrStr , jPath , tagName ) {
196+ function buildAttributesMap ( attrStr , jPath , tagName , force = false ) {
197197 const options = this . options ;
198- if ( options . ignoreAttributes !== true && typeof attrStr === 'string' ) {
198+ if ( force === true || ( options . ignoreAttributes !== true && typeof attrStr === 'string' ) ) {
199199 // attrStr = attrStr.replace(/\r?\n/g, ' ');
200200 //attrStr = attrStr || attrStr.trim();
201201
@@ -339,9 +339,10 @@ const parseXml = function (xmlData) {
339339 if ( ! tagData ) throw new Error ( "Pi Tag is not closed." ) ;
340340
341341 textData = this . saveTextToParentTag ( textData , currentNode , this . readonlyMatcher ) ;
342- const attsMap = this . buildAttributesMap ( tagData . tagExp , this . matcher , tagData . tagName ) ;
343- if ( attsMap && attsMap [ "version" ] ) {
344- this . entityDecoder . setXmlVersion ( attsMap [ "version" ] ) ;
342+ const attsMap = this . buildAttributesMap ( tagData . tagExp , this . matcher , tagData . tagName , true ) ;
343+ if ( attsMap ) {
344+ const ver = attsMap [ this . options . attributeNamePrefix + "version" ] ;
345+ this . entityDecoder . setXmlVersion ( Number ( ver ) || 1.0 ) ;
345346 }
346347 if ( ( options . ignoreDeclaration && tagData . tagName === "?xml" ) || options . ignorePiTags ) {
347348 //do nothing
@@ -350,7 +351,7 @@ const parseXml = function (xmlData) {
350351 const childNode = new xmlNode ( tagData . tagName ) ;
351352 childNode . add ( options . textNodeName , "" ) ;
352353
353- if ( tagData . tagName !== tagData . tagExp && tagData . attrExpPresent ) {
354+ if ( tagData . tagName !== tagData . tagExp && tagData . attrExpPresent && options . ignoreAttributes !== true ) {
354355 childNode [ ":@" ] = attsMap
355356 }
356357 this . addChild ( currentNode , childNode , this . readonlyMatcher , i ) ;
@@ -472,6 +473,7 @@ const parseXml = function (xmlData) {
472473
473474 if ( prefixedAttrs ) {
474475 // Extract raw attributes (without prefix) for our use
476+ //TODO: seems a performance overhead
475477 rawAttrs = extractRawAttributes ( prefixedAttrs , options ) ;
476478 }
477479 }
0 commit comments