FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Node.getLastCommonParent Algorithm · Issue #5 · DaisyDiff/DaisyDiff · GitHub

Node.getLastCommonParent Algorithm #5

Description

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 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


    Back | FazBrowse Home | New Git URL