Skip to content

Commit 5595509

Browse files
committed
fix(XMLDiff): missed removing the attributes
1 parent 0b81ee8 commit 5595509

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

XMLDiff/Program.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -560,19 +560,27 @@ private static bool CompareElements(
560560
}
561561
if (matchedEnough)
562562
{
563-
foreach (var attr in originalAttributes.Keys)
563+
foreach (var attr in originalAttributes)
564564
{
565-
if (!modifiedAttributes.ContainsKey(attr))
565+
if (!modifiedAttributes.ContainsKey(attr.Key))
566566
{
567-
Logger.Debug($"Modified attributes does not contain key '{attr}'.");
567+
Logger.Debug($"Modified attributes does not contain key '{attr.Key}'.");
568568
if (checkOnly)
569569
{
570570
Logger.Debug(
571571
$"Attribute '{attr}' from {GetElementInfo(originalChild)} not exists in {GetElementInfo(modifiedChild)} check only mode. Returning true."
572572
);
573573
return true;
574574
}
575-
matchedEnough = false;
575+
differencesInAttributesCount++;
576+
if (differencesInAttributesCount > 1 || originalAttributes.Count == 1)
577+
{
578+
differencesInAttributesCount++;
579+
matchedEnough = false;
580+
break;
581+
}
582+
string sel = $"{GenerateXPath(originalChild, pathOptions)}/@{attr.Key}";
583+
savedOp = new XElement("remove", new XAttribute("sel", sel));
576584
break;
577585
}
578586
}

0 commit comments

Comments
 (0)