From 2f2f7876ec47e9d52acae1f86af7a276c8689932 Mon Sep 17 00:00:00 2001 From: Maciej Radzikowski Date: Tue, 27 Jun 2023 07:53:18 +0200 Subject: [PATCH] Remove trailing slash from jPath for self-closing tags (#595) --- spec/updateTag_spec.js | 6 ++++++ src/xmlparser/OrderedObjParser.js | 1 + 2 files changed, 7 insertions(+) diff --git a/spec/updateTag_spec.js b/spec/updateTag_spec.js index dbfded3e..4c48f284 100644 --- a/spec/updateTag_spec.js +++ b/spec/updateTag_spec.js @@ -121,6 +121,8 @@ describe("XMLParser updateTag ", function() { + + `; const expected = { @@ -167,6 +169,10 @@ describe("XMLParser updateTag ", function() { if(attrs.width > 200 || attrs.height > 200) return false; }else if(tagname === "content"){ return "div" + }else if(tagname === "lorem") { + return false; + }else if(jPath === "html.body.ipsum") { + return false; } return tagname; }, diff --git a/src/xmlparser/OrderedObjParser.js b/src/xmlparser/OrderedObjParser.js index db11a8c0..db1268a9 100644 --- a/src/xmlparser/OrderedObjParser.js +++ b/src/xmlparser/OrderedObjParser.js @@ -341,6 +341,7 @@ const parseXml = function(xmlData) { if(tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1){ if(tagName[tagName.length - 1] === "/"){ //remove trailing '/' tagName = tagName.substr(0, tagName.length - 1); + jPath = jPath.substr(0, jPath.length - 1); tagExp = tagName; }else{ tagExp = tagExp.substr(0, tagExp.length - 1);