fiduswriter/diffDOM

Diff on string with multiple HTML comments fails

yeldarby opened this issue · 0 comments

If you try to diff a node with a string that contains multiple HTML comments, diffDOM throws an exception.

I've put together a minimal JSFiddle to reproduce the error here: https://jsfiddle.net/hr81vosa/1/

jquery-git.js:3335 Uncaught TypeError: Cannot read property 'childNodes' of undefined
    at fromString.js:168
    at String.replace (<anonymous>)
    at fromString.js:94
    at x (fromString.js:194)
    at new A (diff.js:12)
    at O.diff (index.js:71)
    at HTMLDocument.<anonymous> (?editor_console=true:135)
    at mightThrow (jquery-git.js:3044)
    at process (jquery-git.js:3112)

Parsing this string:

<div id="c">
  <h1>Testing 3</h1>
  <!-- <div id="example1"></div> -->
  <!-- <div id="example2"></div> -->
</div>

Edit: it looks like it only happens if those comments contain HTML tags. Updating to this does not throw an error:

<div id="c">
  <h1>Testing 3</h1>
  <!-- example 1 -->
  <!-- example 2 -->
</div>