You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would expect the module to identify some xml only as equal, if their contents with text-contents and their whitespaces are really the same.
It seems that the module does ignore it, if the one XML has got some spaces somewhere and the other has got a differenz amount of spaces or none at all.
constdom=require('xmldom').DOMParser;constxmlSerializer=require('xmldom').XMLSerializer;constcompare=require('dom-compare').compare;constxmlA=newdom().parseFromString("<foo> </foo>");constxmlB=newdom().parseFromString("<foo></foo>");constxmlC=newdom().parseFromString("<foo> a</foo>");console.log(newxmlSerializer().serializeToString(xmlA));console.log(newxmlSerializer().serializeToString(xmlB));constresultAB=compare(xmlA,xmlB);//empty diff, but should contain " ' ' is not ' ' "constresultBC=compare(xmlB,xmlC);//non-empty diff, because " " is not " a" what is correctconsole.log(resultAB);console.log(resultBC);
"stripSpaces" should be false as default so I don't know what to do to achieve this.
The text was updated successfully, but these errors were encountered:
Hey @Olegas,
the tool compares XML including characters, so why not space-characters? I agree that it's kind of an edge-case, but I thought "stripSpaces=false" would do exactly this.
In my use-case, I fiddle around with XML and HTML, basically rendering XML as HTML, and I use your tool in automated tests to verify whether XMLs are correct at some point.
Sadly, in the HTML-output there's a huge difference between <p>a <span>b</span></p>, which renders like a b and the variant without a space <p>a<span>b</span></p> which renders like ab.
We found the bug when looking at the broken output while the tests still passed.
Any idea on how to achieve this kind of comparison though?
I would expect the module to identify some xml only as equal, if their contents with text-contents and their whitespaces are really the same.
It seems that the module does ignore it, if the one XML has got some spaces somewhere and the other has got a differenz amount of spaces or none at all.
"stripSpaces" should be false as default so I don't know what to do to achieve this.
The text was updated successfully, but these errors were encountered: