@@ -41244,6 +41244,32 @@ module.exports = {
41244
41244
41245
41245
/***/ }),
41246
41246
41247
+ /***/ 4958:
41248
+ /***/ ((module) => {
41249
+
41250
+ function getIgnoreAttributesFn(ignoreAttributes) {
41251
+ if (typeof ignoreAttributes === 'function') {
41252
+ return ignoreAttributes
41253
+ }
41254
+ if (Array.isArray(ignoreAttributes)) {
41255
+ return (attrName) => {
41256
+ for (const pattern of ignoreAttributes) {
41257
+ if (typeof pattern === 'string' && attrName === pattern) {
41258
+ return true
41259
+ }
41260
+ if (pattern instanceof RegExp && pattern.test(attrName)) {
41261
+ return true
41262
+ }
41263
+ }
41264
+ }
41265
+ }
41266
+ return () => false
41267
+ }
41268
+
41269
+ module.exports = getIgnoreAttributesFn
41270
+
41271
+ /***/ }),
41272
+
41247
41273
/***/ 8280:
41248
41274
/***/ ((__unused_webpack_module, exports) => {
41249
41275
@@ -41761,6 +41787,7 @@ function getPositionFromMatch(match) {
41761
41787
41762
41788
//parse Empty Node as self closing node
41763
41789
const buildFromOrderedJs = __nccwpck_require__(2462);
41790
+ const getIgnoreAttributesFn = __nccwpck_require__(4958)
41764
41791
41765
41792
const defaultOptions = {
41766
41793
attributeNamePrefix: '@_',
@@ -41798,11 +41825,12 @@ const defaultOptions = {
41798
41825
41799
41826
function Builder(options) {
41800
41827
this.options = Object.assign({}, defaultOptions, options);
41801
- if (this.options.ignoreAttributes || this.options.attributesGroupName) {
41828
+ if (this.options.ignoreAttributes === true || this.options.attributesGroupName) {
41802
41829
this.isAttribute = function(/*a*/) {
41803
41830
return false;
41804
41831
};
41805
41832
} else {
41833
+ this.ignoreAttributesFn = getIgnoreAttributesFn(this.options.ignoreAttributes)
41806
41834
this.attrPrefixLen = this.options.attributeNamePrefix.length;
41807
41835
this.isAttribute = isAttribute;
41808
41836
}
@@ -41831,13 +41859,14 @@ Builder.prototype.build = function(jObj) {
41831
41859
[this.options.arrayNodeName] : jObj
41832
41860
}
41833
41861
}
41834
- return this.j2x(jObj, 0).val;
41862
+ return this.j2x(jObj, 0, [] ).val;
41835
41863
}
41836
41864
};
41837
41865
41838
- Builder.prototype.j2x = function(jObj, level) {
41866
+ Builder.prototype.j2x = function(jObj, level, ajPath ) {
41839
41867
let attrStr = '';
41840
41868
let val = '';
41869
+ const jPath = ajPath.join('.')
41841
41870
for (let key in jObj) {
41842
41871
if(!Object.prototype.hasOwnProperty.call(jObj, key)) continue;
41843
41872
if (typeof jObj[key] === 'undefined') {
@@ -41860,9 +41889,9 @@ Builder.prototype.j2x = function(jObj, level) {
41860
41889
} else if (typeof jObj[key] !== 'object') {
41861
41890
//premitive type
41862
41891
const attr = this.isAttribute(key);
41863
- if (attr) {
41892
+ if (attr && !this.ignoreAttributesFn(attr, jPath) ) {
41864
41893
attrStr += this.buildAttrPairStr(attr, '' + jObj[key]);
41865
- }else {
41894
+ } else if (!attr) {
41866
41895
//tag value
41867
41896
if (key === this.options.textNodeName) {
41868
41897
let newval = this.options.tagValueProcessor(key, '' + jObj[key]);
@@ -41886,13 +41915,13 @@ Builder.prototype.j2x = function(jObj, level) {
41886
41915
// val += this.indentate(level) + '<' + key + '/' + this.tagEndChar;
41887
41916
} else if (typeof item === 'object') {
41888
41917
if(this.options.oneListGroup){
41889
- const result = this.j2x(item, level + 1);
41918
+ const result = this.j2x(item, level + 1, ajPath.concat(key) );
41890
41919
listTagVal += result.val;
41891
41920
if (this.options.attributesGroupName && item.hasOwnProperty(this.options.attributesGroupName)) {
41892
41921
listTagAttr += result.attrStr
41893
41922
}
41894
41923
}else{
41895
- listTagVal += this.processTextOrObjNode(item, key, level)
41924
+ listTagVal += this.processTextOrObjNode(item, key, level, ajPath )
41896
41925
}
41897
41926
} else {
41898
41927
if (this.options.oneListGroup) {
@@ -41917,7 +41946,7 @@ Builder.prototype.j2x = function(jObj, level) {
41917
41946
attrStr += this.buildAttrPairStr(Ks[j], '' + jObj[key][Ks[j]]);
41918
41947
}
41919
41948
} else {
41920
- val += this.processTextOrObjNode(jObj[key], key, level)
41949
+ val += this.processTextOrObjNode(jObj[key], key, level, ajPath )
41921
41950
}
41922
41951
}
41923
41952
}
@@ -41932,8 +41961,8 @@ Builder.prototype.buildAttrPairStr = function(attrName, val){
41932
41961
} else return ' ' + attrName + '="' + val + '"';
41933
41962
}
41934
41963
41935
- function processTextOrObjNode (object, key, level) {
41936
- const result = this.j2x(object, level + 1);
41964
+ function processTextOrObjNode (object, key, level, ajPath ) {
41965
+ const result = this.j2x(object, level + 1, ajPath.concat(key) );
41937
41966
if (object[this.options.textNodeName] !== undefined && Object.keys(object).length === 1) {
41938
41967
return this.buildTextValNode(object[this.options.textNodeName], key, result.attrStr, level);
41939
41968
} else {
@@ -42408,6 +42437,7 @@ const util = __nccwpck_require__(8280);
42408
42437
const xmlNode = __nccwpck_require__(7462);
42409
42438
const readDocType = __nccwpck_require__(6072);
42410
42439
const toNumber = __nccwpck_require__(4526);
42440
+ const getIgnoreAttributesFn = __nccwpck_require__(4958)
42411
42441
42412
42442
// const regx =
42413
42443
// '<((!\\[CDATA\\[([\\s\\S]*?)(]]>))|((NAME:)?(NAME))([^>]*)>|((\\/)(NAME)\\s*>))([^<]*)'
@@ -42456,6 +42486,7 @@ class OrderedObjParser{
42456
42486
this.readStopNodeData = readStopNodeData;
42457
42487
this.saveTextToParentTag = saveTextToParentTag;
42458
42488
this.addChild = addChild;
42489
+ this.ignoreAttributesFn = getIgnoreAttributesFn(this.options.ignoreAttributes)
42459
42490
}
42460
42491
42461
42492
}
@@ -42528,7 +42559,7 @@ function resolveNameSpace(tagname) {
42528
42559
const attrsRegx = new RegExp('([^\\s=]+)\\s*(=\\s*([\'"])([\\s\\S]*?)\\3)?', 'gm');
42529
42560
42530
42561
function buildAttributesMap(attrStr, jPath, tagName) {
42531
- if (! this.options.ignoreAttributes && typeof attrStr === 'string') {
42562
+ if (this.options.ignoreAttributes !== true && typeof attrStr === 'string') {
42532
42563
// attrStr = attrStr.replace(/\r?\n/g, ' ');
42533
42564
//attrStr = attrStr || attrStr.trim();
42534
42565
@@ -42537,6 +42568,9 @@ function buildAttributesMap(attrStr, jPath, tagName) {
42537
42568
const attrs = {};
42538
42569
for (let i = 0; i < len; i++) {
42539
42570
const attrName = this.resolveNameSpace(matches[i][1]);
42571
+ if (this.ignoreAttributesFn(attrName, jPath)) {
42572
+ continue
42573
+ }
42540
42574
let oldVal = matches[i][4];
42541
42575
let aName = this.options.attributeNamePrefix + attrName;
42542
42576
if (attrName.length) {
@@ -44660,7 +44694,7 @@ var y = d * 365.25;
44660
44694
* @api public
44661
44695
*/
44662
44696
44663
- module.exports = function(val, options) {
44697
+ module.exports = function (val, options) {
44664
44698
options = options || {};
44665
44699
var type = typeof val;
44666
44700
if (type === 'string' && val.length > 0) {
0 commit comments