benjamine / jsondiffpatch

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

Javascript code returned as part of html formatter #265

Open JipsaY opened 5 years ago

JipsaY commented 5 years ago

Hi, While using html formatter. I get javascript code returned as part of diff. Looks like the moving arrows are not getting generated incase of array index change. Is there something I am missing here.

severity type 0 10 setTimeout(function (t){var e=t||document;!function(t,n,i){for(var r=e.querySelectorAll(".jsondiffpatch-arrow"),o=0,l=r.length;o<l;o++)i(r[o])}(0,0,function(t){var e=t.style,n=t.parentNode,i=t.children[0],r=i.children[1];i.style.display="none";var o,l=(o=n.querySelector(".jsondiffpatch-moved-destination")).textContent||o.innerText,a=n.parentNode,s=void 0;if(function(t,e){for(var n=a.children,i=0,r=n.length;i<r;i++)(o=n[i]).getAttribute("data-key")===l&&(s=o);var o}(),s)try{var u=s.offsetTop-n.offsetTop;i.setAttribute("height",Math.abs(u)+6),e.top=-8+(u>0?0:u)+"px";var c=u>0?"M30,0 Q-10,"+Math.round(u/2)+" 26,"+(u-4):"M30,"+-u+" Q-10,"+Math.round(-u/2)+" 26,4";r.setAttribute("d",c),i.style.display=""}catch(d){}})},10);

JipsaY commented 5 years ago

For some reason I am unable to attach the screen shot.

jvpepino commented 4 years ago

Did you ever get a resolution to this?

kimpixel commented 1 year ago

This is a problem with react.

came up with this hook:

React.useEffect(() => {
  var extractscript=/<script.*?>(.+)<\/script>/gi.exec(html);
  window.eval(extractscript[1]);
});