Hi - I'm wondering if anyone could shed some light on the Node.getLastCommonParent() method. If we have the following hierarchy and we're trying to find where to add some deleted text..then supposing an invocation of
node.getLastCommonParent(otherNode)
where
node.getParentTree() => [body, div, p class=foo, span id=_123]
otherNode.getParentTree() => [body, div, p class=bar, span id=_123]
the "last" common ancestor is deemed to be the div at index 1. The algorithm starts from the root and works down until it finds a node that is different in each list, in this instance getting as far as the p tag at index 2 and since they have different classes in both trees, it thinks the previous entry is the last common parent. The issue this seems to cause is that DaisyDiff then places the removed text beneath that div. It would seem to me that since the two nodes have the same parent in both trees, that node should be selected ? i.e. we would want to show the deleted text under the span id=_123.
Is there some fundamental reason I'm failing to grasp that informed the algorithm in getLastCommonParent ?
Reactions are currently unavailable
Hi - I'm wondering if anyone could shed some light on the Node.getLastCommonParent() method. If we have the following hierarchy and we're trying to find where to add some deleted text..then supposing an invocation of
node.getLastCommonParent(otherNode)
where
node.getParentTree() => [body, div, p class=foo, span id=_123]
otherNode.getParentTree() => [body, div, p class=bar, span id=_123]
the "last" common ancestor is deemed to be the div at index 1. The algorithm starts from the root and works down until it finds a node that is different in each list, in this instance getting as far as the p tag at index 2 and since they have different classes in both trees, it thinks the previous entry is the last common parent. The issue this seems to cause is that DaisyDiff then places the removed text beneath that div. It would seem to me that since the two nodes have the same parent in both trees, that node should be selected ? i.e. we would want to show the deleted text under the span id=_123.
Is there some fundamental reason I'm failing to grasp that informed the algorithm in getLastCommonParent ?