benjamine / jsondiffpatch

Diff & patch JavaScript objects
MIT License
4.85k stars 472 forks source link

Update hideUnchanged/showUnchanged in Formatters doc so formatter arrows are shown #206

Open gterras opened 6 years ago

gterras commented 6 years ago

The current example in https://github.com/benjamine/jsondiffpatch/blob/master/docs/formatters.md does not trigger html arrows display.

This is the closest I've came up with to make it work :

  var delta = jsondiffpatch.diff(left, right);
  // left is optional, if specified unchanged values will be visible too

  var el = document.getElementById('the-diff');

 el.innerHTML = jsondiffpatch.formatters.html.format(delta, left);

  // Also you can dinamically show/hide unchanged values
  jsondiffpatch.formatters.html.hideUnchanged(el,10);
  jsondiffpatch.formatters.html.showUnchanged(true, el, 10);
  // these will also adjust array move arrows (SVG), which is useful if something alters the html layout