Implement isSameTree(nodeA, nodeB). It returns true if the two DOM nodes are structurally identical and false otherwise. Do not use isEqualNode, outerHTML or innerHTML.
Two nodes are identical when:
nodeType.nodeValue.const a = document.createElement('div');
a.innerHTML = '<p class="x" id="1">Hi <b>there</b></p>';
const b = document.createElement('div');
b.innerHTML = '<p id="1" class="x">Hi <b>there</b></p>';
isSameTree(a, b); // true: attribute order doesn't matter
b.querySelector('b').textContent = 'you';
isSameTree(a, b); // false
class="a b" is not the same as class="b a").outerHTML strings a weaker check than it looks?Spotted a mistake or a rights concern? Report an issue