Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complex diff result #122

Open
iowxy opened this issue Jul 7, 2023 · 1 comment
Open

Complex diff result #122

iowxy opened this issue Jul 7, 2023 · 1 comment

Comments

@iowxy
Copy link

iowxy commented Jul 7, 2023

Versioun

5.0.4

Original dom

<p>1</p><p>2</p><p>3</p>

Next dom

<p>1</p><b>2</b><p>3</p>

Expected result

[
  {
    "action": "replaceElement",
    "route": [1]
  }
]

Actual diff result

{
    "action": "removeElement",
    "route": [  0  ],
    "element": {
      "nodeName": "P",
      "childNodes": [
        {
          "nodeName": "#text",
          "data": "1"
        }
      ]
    }
  },
  {
    "action": "addElement",
    "route": [ 1 ],
    "element": {
      "nodeName": "B",
      "childNodes": [
        {
          "nodeName": "#text",
          "data": "2",
          "outerDone": true
        }
      ],
      "outerDone": true,
      "subsets": [
        {
          "oldValue": 0,
          "newValue": 0,
          "length": 1
        }
      ],
      "subsetsAge": 100,
      "innerDone": true,
      "valueDone": true
    }
  },
  {
    "action": "modifyTextElement",
    "route": [  0, 0  ],
    "oldValue": "2",
    "newValue": "1"
  }
@johanneswilm
Copy link
Member

@iowxy True. However, this is more difficult than one would assume as optimizing the algorithm for this usecase will probably make it worse for other use cases. I have started some work here, but will probably not finish it. I will accept a PR though.
https://github.com/fiduswriter/diffDOM/tree/similarity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants