Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

diff-dom

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

diff-dom - npm Package Compare versions

Comparing version 5.1.0 to 5.1.1

browser/dist/dts/diffDOM/dom/apply.d.ts

2

browser/diffDOM.js

@@ -1,2 +0,2 @@

var diffDOM=function(e){"use strict";function t(e,n,o){var s;return"#text"===e.nodeName?s=o.document.createTextNode(e.data):"#comment"===e.nodeName?s=o.document.createComment(e.data):(n?s=o.document.createElementNS("http://www.w3.org/2000/svg",e.nodeName):"svg"===e.nodeName.toLowerCase()?(s=o.document.createElementNS("http://www.w3.org/2000/svg","svg"),n=!0):s=o.document.createElement(e.nodeName),e.attributes&&Object.entries(e.attributes).forEach((function(e){var t=e[0],n=e[1];return s.setAttribute(t,n)})),e.childNodes&&e.childNodes.forEach((function(e){return s.appendChild(t(e,n,o))})),o.valueDiffing&&(e.value&&(s instanceof HTMLButtonElement||s instanceof HTMLDataElement||s instanceof HTMLInputElement||s instanceof HTMLLIElement||s instanceof HTMLMeterElement||s instanceof HTMLOptionElement||s instanceof HTMLProgressElement||s instanceof HTMLParamElement)&&(s.value=e.value),e.checked&&s instanceof HTMLInputElement&&(s.checked=e.checked),e.selected&&s instanceof HTMLOptionElement&&(s.selected=e.selected))),s}var n=function(e,t){for(t=t.slice();t.length>0;){var n=t.splice(0,1)[0];e=e.childNodes[n]}return e};function o(e,o,s){var i,a,c,l=o[s._const.action],r=o[s._const.route];[s._const.addElement,s._const.addTextElement].includes(l)||(i=n(e,r));var u={diff:o,node:i};if(s.preDiffApply(u))return!0;switch(l){case s._const.addAttribute:if(!(i&&i instanceof Element))return!1;i.setAttribute(o[s._const.name],o[s._const.value]);break;case s._const.modifyAttribute:if(!(i&&i instanceof Element))return!1;i.setAttribute(o[s._const.name],o[s._const.newValue]),i instanceof HTMLInputElement&&"value"===o[s._const.name]&&(i.value=o[s._const.newValue]);break;case s._const.removeAttribute:if(!(i&&i instanceof Element))return!1;i.removeAttribute(o[s._const.name]);break;case s._const.modifyTextElement:if(!(i&&i instanceof Text))return!1;s.textDiff(i,i.data,o[s._const.oldValue],o[s._const.newValue]),i.parentNode instanceof HTMLTextAreaElement&&(i.parentNode.value=o[s._const.newValue]);break;case s._const.modifyValue:if(!i||void 0===i.value)return!1;i.value=o[s._const.newValue];break;case s._const.modifyComment:if(!(i&&i instanceof Comment))return!1;s.textDiff(i,i.data,o[s._const.oldValue],o[s._const.newValue]);break;case s._const.modifyChecked:if(!i||void 0===i.checked)return!1;i.checked=o[s._const.newValue];break;case s._const.modifySelected:if(!i||void 0===i.selected)return!1;i.selected=o[s._const.newValue];break;case s._const.replaceElement:var d="svg"===o[s._const.newValue].nodeName.toLowerCase()||"http://www.w3.org/2000/svg"===i.parentNode.namespaceURI;i.parentNode.replaceChild(t(o[s._const.newValue],d,s),i);break;case s._const.relocateGroup:Array.apply(void 0,new Array(o[s._const.groupLength])).map((function(){return i.removeChild(i.childNodes[o[s._const.from]])})).forEach((function(e,t){0===t&&(c=i.childNodes[o[s._const.to]]),i.insertBefore(e,c||null)}));break;case s._const.removeElement:i.parentNode.removeChild(i);break;case s._const.addElement:var h=(p=r.slice()).splice(p.length-1,1)[0];if(!((i=n(e,p))instanceof Element))return!1;i.insertBefore(t(o[s._const.element],"http://www.w3.org/2000/svg"===i.namespaceURI,s),i.childNodes[h]||null);break;case s._const.removeTextElement:if(!i||3!==i.nodeType)return!1;var f=i.parentNode;f.removeChild(i),f instanceof HTMLTextAreaElement&&(f.value="");break;case s._const.addTextElement:var p;h=(p=r.slice()).splice(p.length-1,1)[0];if(a=s.document.createTextNode(o[s._const.value]),!(i=n(e,p)).childNodes)return!1;i.insertBefore(a,i.childNodes[h]||null),i.parentNode instanceof HTMLTextAreaElement&&(i.parentNode.value=o[s._const.value]);break;default:console.log("unknown action")}return s.postDiffApply({diff:u.diff,node:u.node,newNode:a}),!0}function s(e,t,n){var o=e[t];e[t]=e[n],e[n]=o}function i(e,t,n){(t=t.slice()).reverse(),t.forEach((function(t){!function(e,t,n){switch(t[n._const.action]){case n._const.addAttribute:t[n._const.action]=n._const.removeAttribute,o(e,t,n);break;case n._const.modifyAttribute:s(t,n._const.oldValue,n._const.newValue),o(e,t,n);break;case n._const.removeAttribute:t[n._const.action]=n._const.addAttribute,o(e,t,n);break;case n._const.modifyTextElement:case n._const.modifyValue:case n._const.modifyComment:case n._const.modifyChecked:case n._const.modifySelected:case n._const.replaceElement:s(t,n._const.oldValue,n._const.newValue),o(e,t,n);break;case n._const.relocateGroup:s(t,n._const.from,n._const.to),o(e,t,n);break;case n._const.removeElement:t[n._const.action]=n._const.addElement,o(e,t,n);break;case n._const.addElement:t[n._const.action]=n._const.removeElement,o(e,t,n);break;case n._const.removeTextElement:t[n._const.action]=n._const.addTextElement,o(e,t,n);break;case n._const.addTextElement:t[n._const.action]=n._const.removeTextElement,o(e,t,n);break;default:console.log("unknown action")}}(e,t,n)}))}var a=function(){return a=Object.assign||function(e){for(var t,n=arguments,o=1,s=arguments.length;o<s;o++)for(var i in t=n[o])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},a.apply(this,arguments)},c=function(e){var t=[];return t.push(e.nodeName),"#text"!==e.nodeName&&"#comment"!==e.nodeName&&e.attributes&&(e.attributes.class&&t.push("".concat(e.nodeName,".").concat(e.attributes.class.replace(/ /g,"."))),e.attributes.id&&t.push("".concat(e.nodeName,"#").concat(e.attributes.id))),t},l=function(e){var t={},n={};return e.forEach((function(e){c(e).forEach((function(e){var o=e in t;o||e in n?o&&(delete t[e],n[e]=!0):t[e]=!0}))})),t},r=function(e,t){var n=l(e),o=l(t),s={};return Object.keys(n).forEach((function(e){o[e]&&(s[e]=!0)})),s},u=function(e){return delete e.outerDone,delete e.innerDone,delete e.valueDone,!e.childNodes||e.childNodes.every(u)},d=function(e){if(Object.prototype.hasOwnProperty.call(e,"data"))return{nodeName:"#text"===e.nodeName?"#text":"#comment",data:e.data};var t={nodeName:e.nodeName};return Object.prototype.hasOwnProperty.call(e,"attributes")&&(t.attributes=a({},e.attributes)),Object.prototype.hasOwnProperty.call(e,"checked")&&(t.checked=e.checked),Object.prototype.hasOwnProperty.call(e,"value")&&(t.value=e.value),Object.prototype.hasOwnProperty.call(e,"selected")&&(t.selected=e.selected),Object.prototype.hasOwnProperty.call(e,"childNodes")&&(t.childNodes=e.childNodes.map((function(e){return d(e)}))),t},h=function(e,t){if(!["nodeName","value","checked","selected","data"].every((function(n){return e[n]===t[n]})))return!1;if(Object.prototype.hasOwnProperty.call(e,"data"))return!0;if(Boolean(e.attributes)!==Boolean(t.attributes))return!1;if(Boolean(e.childNodes)!==Boolean(t.childNodes))return!1;if(e.attributes){var n=Object.keys(e.attributes),o=Object.keys(t.attributes);if(n.length!==o.length)return!1;if(!n.every((function(n){return e.attributes[n]===t.attributes[n]})))return!1}if(e.childNodes){if(e.childNodes.length!==t.childNodes.length)return!1;if(!e.childNodes.every((function(e,n){return h(e,t.childNodes[n])})))return!1}return!0},f=function(e,t,n,o,s){if(void 0===s&&(s=!1),!e||!t)return!1;if(e.nodeName!==t.nodeName)return!1;if(["#text","#comment"].includes(e.nodeName))return!!s||e.data===t.data;if(e.nodeName in n)return!0;if(e.attributes&&t.attributes){if(e.attributes.id){if(e.attributes.id!==t.attributes.id)return!1;if("".concat(e.nodeName,"#").concat(e.attributes.id)in n)return!0}if(e.attributes.class&&e.attributes.class===t.attributes.class)if("".concat(e.nodeName,".").concat(e.attributes.class.replace(/ /g,"."))in n)return!0}if(o)return!0;var i=e.childNodes?e.childNodes.slice().reverse():[],a=t.childNodes?t.childNodes.slice().reverse():[];if(i.length!==a.length)return!1;if(s)return i.every((function(e,t){return e.nodeName===a[t].nodeName}));var c=r(i,a);return i.every((function(e,t){return f(e,a[t],c,!0,!0)}))},p=function(e,t){return Array.apply(void 0,new Array(e)).map((function(){return t}))},m=function(e,t){for(var n=e.childNodes?e.childNodes:[],o=t.childNodes?t.childNodes:[],s=p(n.length,!1),i=p(o.length,!1),a=[],l=function(){return arguments[1]},u=!1,d=function(){var e=function(e,t,n,o){var s=0,i=[],a=e.length,l=t.length,u=Array.apply(void 0,new Array(a+1)).map((function(){return[]})),d=r(e,t),h=a===l;h&&e.some((function(e,n){var o=c(e),s=c(t[n]);return o.length!==s.length?(h=!1,!0):(o.some((function(e,t){if(e!==s[t])return h=!1,!0})),!h||void 0)}));for(var p=0;p<a;p++)for(var m=e[p],_=0;_<l;_++){var v=t[_];n[p]||o[_]||!f(m,v,d,h)?u[p+1][_+1]=0:(u[p+1][_+1]=u[p][_]?u[p][_]+1:1,u[p+1][_+1]>=s&&(s=u[p+1][_+1],i=[p+1,_+1]))}return 0!==s&&{oldValue:i[0]-s,newValue:i[1]-s,length:s}}(n,o,s,i);e?(a.push(e),Array.apply(void 0,new Array(e.length)).map(l).forEach((function(t){return function(e,t,n,o){e[n.oldValue+o]=!0,t[n.newValue+o]=!0}(s,i,e,t)}))):u=!0};!u;)d();return e.subsets=a,e.subsetsAge=100,a},_=function(){function e(){this.list=[]}return e.prototype.add=function(e){var t;(t=this.list).push.apply(t,e)},e.prototype.forEach=function(e){this.list.forEach((function(t){return e(t)}))},e}(),v=function(){function e(e){void 0===e&&(e={});var t=this;Object.entries(e).forEach((function(e){var n=e[0],o=e[1];return t[n]=o}))}return e.prototype.toString=function(){return JSON.stringify(this)},e.prototype.setValue=function(e,t){return this[e]=t,this},e}();function V(e,t){var n,o,s=e;for(t=t.slice();t.length>0;)o=t.splice(0,1)[0],n=s,s=s.childNodes?s.childNodes[o]:void 0;return{node:s,parentNode:n,nodeIndex:o}}function g(e,t,n){return t.forEach((function(t){!function(e,t,n){var o,s,i,a;if(![n._const.addElement,n._const.addTextElement].includes(t[n._const.action])){var c=V(e,t[n._const.route]);s=c.node,i=c.parentNode,a=c.nodeIndex}var l,r,u=[],h={diff:t,node:s};if(n.preVirtualDiffApply(h))return!0;switch(t[n._const.action]){case n._const.addAttribute:s.attributes||(s.attributes={}),s.attributes[t[n._const.name]]=t[n._const.value],"checked"===t[n._const.name]?s.checked=!0:"selected"===t[n._const.name]?s.selected=!0:"INPUT"===s.nodeName&&"value"===t[n._const.name]&&(s.value=t[n._const.value]);break;case n._const.modifyAttribute:s.attributes[t[n._const.name]]=t[n._const.newValue];break;case n._const.removeAttribute:delete s.attributes[t[n._const.name]],0===Object.keys(s.attributes).length&&delete s.attributes,"checked"===t[n._const.name]?s.checked=!1:"selected"===t[n._const.name]?delete s.selected:"INPUT"===s.nodeName&&"value"===t[n._const.name]&&delete s.value;break;case n._const.modifyTextElement:s.data=t[n._const.newValue],"TEXTAREA"===i.nodeName&&(i.value=t[n._const.newValue]);break;case n._const.modifyValue:s.value=t[n._const.newValue];break;case n._const.modifyComment:s.data=t[n._const.newValue];break;case n._const.modifyChecked:s.checked=t[n._const.newValue];break;case n._const.modifySelected:s.selected=t[n._const.newValue];break;case n._const.replaceElement:l=d(t[n._const.newValue]),i.childNodes[a]=l;break;case n._const.relocateGroup:s.childNodes.splice(t[n._const.from],t[n._const.groupLength]).reverse().forEach((function(e){return s.childNodes.splice(t[n._const.to],0,e)})),s.subsets&&s.subsets.forEach((function(e){if(t[n._const.from]<t[n._const.to]&&e.oldValue<=t[n._const.to]&&e.oldValue>t[n._const.from])e.oldValue-=t[n._const.groupLength],(o=e.oldValue+e.length-t[n._const.to])>0&&(u.push({oldValue:t[n._const.to]+t[n._const.groupLength],newValue:e.newValue+e.length-o,length:o}),e.length-=o);else if(t[n._const.from]>t[n._const.to]&&e.oldValue>t[n._const.to]&&e.oldValue<t[n._const.from]){var o;e.oldValue+=t[n._const.groupLength],(o=e.oldValue+e.length-t[n._const.to])>0&&(u.push({oldValue:t[n._const.to]+t[n._const.groupLength],newValue:e.newValue+e.length-o,length:o}),e.length-=o)}else e.oldValue===t[n._const.from]&&(e.oldValue=t[n._const.to])}));break;case n._const.removeElement:i.childNodes.splice(a,1),i.subsets&&i.subsets.forEach((function(e){e.oldValue>a?e.oldValue-=1:e.oldValue===a?e.delete=!0:e.oldValue<a&&e.oldValue+e.length>a&&(e.oldValue+e.length-1===a?e.length--:(u.push({newValue:e.newValue+a-e.oldValue,oldValue:a,length:e.length-a+e.oldValue-1}),e.length=a-e.oldValue))})),s=i;break;case n._const.addElement:var f=(r=t[n._const.route].slice()).splice(r.length-1,1)[0];s=null===(o=V(e,r))||void 0===o?void 0:o.node,l=d(t[n._const.element]),s.childNodes||(s.childNodes=[]),f>=s.childNodes.length?s.childNodes.push(l):s.childNodes.splice(f,0,l),s.subsets&&s.subsets.forEach((function(e){if(e.oldValue>=f)e.oldValue+=1;else if(e.oldValue<f&&e.oldValue+e.length>f){var t=e.oldValue+e.length-f;u.push({newValue:e.newValue+e.length-t,oldValue:f+1,length:t}),e.length-=t}}));break;case n._const.removeTextElement:i.childNodes.splice(a,1),"TEXTAREA"===i.nodeName&&delete i.value,i.subsets&&i.subsets.forEach((function(e){e.oldValue>a?e.oldValue-=1:e.oldValue===a?e.delete=!0:e.oldValue<a&&e.oldValue+e.length>a&&(e.oldValue+e.length-1===a?e.length--:(u.push({newValue:e.newValue+a-e.oldValue,oldValue:a,length:e.length-a+e.oldValue-1}),e.length=a-e.oldValue))})),s=i;break;case n._const.addTextElement:var p=(r=t[n._const.route].slice()).splice(r.length-1,1)[0];l={nodeName:"#text",data:t[n._const.value]},(s=V(e,r).node).childNodes||(s.childNodes=[]),p>=s.childNodes.length?s.childNodes.push(l):s.childNodes.splice(p,0,l),"TEXTAREA"===s.nodeName&&(s.value=t[n._const.newValue]),s.subsets&&s.subsets.forEach((function(e){if(e.oldValue>=p&&(e.oldValue+=1),e.oldValue<p&&e.oldValue+e.length>p){var t=e.oldValue+e.length-p;u.push({newValue:e.newValue+e.length-t,oldValue:p+1,length:t}),e.length-=t}}));break;default:console.log("unknown action")}s.subsets&&(s.subsets=s.subsets.filter((function(e){return!e.delete&&e.oldValue!==e.newValue})),u.length&&(s.subsets=s.subsets.concat(u))),n.postVirtualDiffApply({node:h.node,diff:h.diff,newNode:l})}(e,t,n)})),!0}function b(e,t){void 0===t&&(t={valueDiffing:!0});var n={nodeName:e.nodeName};if(e instanceof Text||e instanceof Comment)n.data=e.data;else{if(e.attributes&&e.attributes.length>0)n.attributes={},Array.prototype.slice.call(e.attributes).forEach((function(e){return n.attributes[e.name]=e.value}));if(e.childNodes&&e.childNodes.length>0)n.childNodes=[],Array.prototype.slice.call(e.childNodes).forEach((function(e){return n.childNodes.push(b(e,t))}));t.valueDiffing&&(e instanceof HTMLTextAreaElement&&(n.value=e.value),e instanceof HTMLInputElement&&["radio","checkbox"].includes(e.type.toLowerCase())&&void 0!==e.checked?n.checked=e.checked:(e instanceof HTMLButtonElement||e instanceof HTMLDataElement||e instanceof HTMLInputElement||e instanceof HTMLLIElement||e instanceof HTMLMeterElement||e instanceof HTMLOptionElement||e instanceof HTMLProgressElement||e instanceof HTMLParamElement)&&(n.value=e.value),e instanceof HTMLOptionElement&&(n.selected=e.selected))}return n}var N=/<\s*\/*[a-zA-Z:_][a-zA-Z0-9:_\-.]*\s*(?:"[^"]*"['"]*|'[^']*'['"]*|[^'"/>])*\/*\s*>|<!--(?:.|\n|\r)*?-->/g,y=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function w(e){return e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&")}var E={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,menuItem:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},k=function(e,t){var n={nodeName:"",attributes:{}},o=!1,s=e.match(/<\/?([^\s]+?)[/\s>]/);if(s&&(n.nodeName=t||"svg"===s[1]?s[1]:s[1].toUpperCase(),(E[s[1]]||"/"===e.charAt(e.length-2))&&(o=!0),n.nodeName.startsWith("!--"))){var i=e.indexOf("--\x3e");return{type:"comment",node:{nodeName:"#comment",data:-1!==i?e.slice(4,i):""},voidElement:o}}for(var a=new RegExp(y),c=null,l=!1;!l;)if(null===(c=a.exec(e)))l=!0;else if(c[0].trim())if(c[1]){var r=c[1].trim(),u=[r,""];r.indexOf("=")>-1&&(u=r.split("=")),n.attributes[u[0]]=u[1],a.lastIndex--}else c[2]&&(n.attributes[c[2]]=c[3].trim().substring(1,c[3].length-1));return{type:"tag",node:n,voidElement:o}},x=function(e,t){void 0===t&&(t={valueDiffing:!0,caseSensitive:!1});var n,o=[],s=-1,i=[],a=!1;if(0!==e.indexOf("<")){var c=e.indexOf("<");o.push({nodeName:"#text",data:-1===c?e:e.substring(0,c)})}return e.replace(N,(function(c,l){var r="/"!==c.charAt(1),u=c.startsWith("\x3c!--"),d=l+c.length,h=e.charAt(d);if(u){var f=k(c,t.caseSensitive).node;if(s<0)return o.push(f),"";var p=i[s];return p&&f.nodeName&&(p.node.childNodes||(p.node.childNodes=[]),p.node.childNodes.push(f)),""}if(r){if("svg"===(n=k(c,t.caseSensitive||a)).node.nodeName&&(a=!0),s++,!n.voidElement&&h&&"<"!==h){n.node.childNodes||(n.node.childNodes=[]);var m=w(e.slice(d,e.indexOf("<",d)));n.node.childNodes.push({nodeName:"#text",data:m}),t.valueDiffing&&"TEXTAREA"===n.node.nodeName&&(n.node.value=m)}0===s&&n.node.nodeName&&o.push(n.node);var _=i[s-1];_&&n.node.nodeName&&(_.node.childNodes||(_.node.childNodes=[]),_.node.childNodes.push(n.node)),i[s]=n}if((!r||n.voidElement)&&(s>-1&&(n.voidElement||t.caseSensitive&&n.node.nodeName===c.slice(2,-1)||!t.caseSensitive&&n.node.nodeName.toUpperCase()===c.slice(2,-1).toUpperCase())&&--s>-1&&("svg"===n.node.nodeName&&(a=!1),n=i[s]),"<"!==h&&h)){var v=-1===s?o:i[s].node.childNodes||[],V=e.indexOf("<",d);m=w(e.slice(d,-1===V?void 0:V));v.push({nodeName:"#text",data:m})}return""})),o[0]},T=function(){function e(e,t,n){this.options=n,this.t1="undefined"!=typeof Element&&e instanceof Element?b(e,this.options):"string"==typeof e?x(e,this.options):JSON.parse(JSON.stringify(e)),this.t2="undefined"!=typeof Element&&t instanceof Element?b(t,this.options):"string"==typeof t?x(t,this.options):JSON.parse(JSON.stringify(t)),this.diffcount=0,this.foundAll=!1,this.debug&&(this.t1Orig="undefined"!=typeof Element&&e instanceof Element?b(e,this.options):"string"==typeof e?x(e,this.options):JSON.parse(JSON.stringify(e)),this.t2Orig="undefined"!=typeof Element&&t instanceof Element?b(t,this.options):"string"==typeof t?x(t,this.options):JSON.parse(JSON.stringify(t))),this.tracker=new _}return e.prototype.init=function(){return this.findDiffs(this.t1,this.t2)},e.prototype.findDiffs=function(e,t){var n;do{if(this.options.debug&&(this.diffcount+=1,this.diffcount>this.options.diffcap))throw new Error("surpassed diffcap:".concat(JSON.stringify(this.t1Orig)," -> ").concat(JSON.stringify(this.t2Orig)));0===(n=this.findNextDiff(e,t,[])).length&&(h(e,t)||(this.foundAll?console.error("Could not find remaining diffs!"):(this.foundAll=!0,u(e),n=this.findNextDiff(e,t,[])))),n.length>0&&(this.foundAll=!1,this.tracker.add(n),g(e,n,this.options))}while(n.length>0);return this.tracker.list},e.prototype.findNextDiff=function(e,t,n){var o,s;if(this.options.maxDepth&&n.length>this.options.maxDepth)return[];if(!e.outerDone){if(o=this.findOuterDiff(e,t,n),this.options.filterOuterDiff&&(s=this.options.filterOuterDiff(e,t,o))&&(o=s),o.length>0)return e.outerDone=!0,o;e.outerDone=!0}if(Object.prototype.hasOwnProperty.call(e,"data"))return[];if(!e.innerDone){if((o=this.findInnerDiff(e,t,n)).length>0)return o;e.innerDone=!0}if(this.options.valueDiffing&&!e.valueDone){if((o=this.findValueDiff(e,t,n)).length>0)return e.valueDone=!0,o;e.valueDone=!0}return[]},e.prototype.findOuterDiff=function(e,t,n){var o,s,i,a,c,l,r=[];if(e.nodeName!==t.nodeName){if(!n.length)throw new Error("Top level nodes have to be of the same kind.");return[(new v).setValue(this.options._const.action,this.options._const.replaceElement).setValue(this.options._const.oldValue,d(e)).setValue(this.options._const.newValue,d(t)).setValue(this.options._const.route,n)]}if(n.length&&this.options.diffcap<Math.abs((e.childNodes||[]).length-(t.childNodes||[]).length))return[(new v).setValue(this.options._const.action,this.options._const.replaceElement).setValue(this.options._const.oldValue,d(e)).setValue(this.options._const.newValue,d(t)).setValue(this.options._const.route,n)];if(Object.prototype.hasOwnProperty.call(e,"data")&&e.data!==t.data)return"#text"===e.nodeName?[(new v).setValue(this.options._const.action,this.options._const.modifyTextElement).setValue(this.options._const.route,n).setValue(this.options._const.oldValue,e.data).setValue(this.options._const.newValue,t.data)]:[(new v).setValue(this.options._const.action,this.options._const.modifyComment).setValue(this.options._const.route,n).setValue(this.options._const.oldValue,e.data).setValue(this.options._const.newValue,t.data)];for(s=e.attributes?Object.keys(e.attributes).sort():[],i=t.attributes?Object.keys(t.attributes).sort():[],a=s.length,l=0;l<a;l++)o=s[l],-1===(c=i.indexOf(o))?r.push((new v).setValue(this.options._const.action,this.options._const.removeAttribute).setValue(this.options._const.route,n).setValue(this.options._const.name,o).setValue(this.options._const.value,e.attributes[o])):(i.splice(c,1),e.attributes[o]!==t.attributes[o]&&r.push((new v).setValue(this.options._const.action,this.options._const.modifyAttribute).setValue(this.options._const.route,n).setValue(this.options._const.name,o).setValue(this.options._const.oldValue,e.attributes[o]).setValue(this.options._const.newValue,t.attributes[o])));for(a=i.length,l=0;l<a;l++)o=i[l],r.push((new v).setValue(this.options._const.action,this.options._const.addAttribute).setValue(this.options._const.route,n).setValue(this.options._const.name,o).setValue(this.options._const.value,t.attributes[o]));return r},e.prototype.findInnerDiff=function(e,t,n){var o=e.childNodes?e.childNodes.slice():[],s=t.childNodes?t.childNodes.slice():[],i=Math.max(o.length,s.length),a=Math.abs(o.length-s.length),c=[],l=0;if(!this.options.maxChildCount||i<this.options.maxChildCount){var r=Boolean(e.subsets&&e.subsetsAge--),u=r?e.subsets:e.childNodes&&t.childNodes?m(e,t):[];if(u.length>0&&(c=this.attemptGroupRelocation(e,t,u,n,r)).length>0)return c}for(var f=0;f<i;f+=1){var p=o[f],_=s[f];a&&(p&&!_?"#text"===p.nodeName?(c.push((new v).setValue(this.options._const.action,this.options._const.removeTextElement).setValue(this.options._const.route,n.concat(l)).setValue(this.options._const.value,p.data)),l-=1):(c.push((new v).setValue(this.options._const.action,this.options._const.removeElement).setValue(this.options._const.route,n.concat(l)).setValue(this.options._const.element,d(p))),l-=1):_&&!p&&("#text"===_.nodeName?c.push((new v).setValue(this.options._const.action,this.options._const.addTextElement).setValue(this.options._const.route,n.concat(l)).setValue(this.options._const.value,_.data)):c.push((new v).setValue(this.options._const.action,this.options._const.addElement).setValue(this.options._const.route,n.concat(l)).setValue(this.options._const.element,d(_))))),p&&_&&(!this.options.maxChildCount||i<this.options.maxChildCount?c=c.concat(this.findNextDiff(p,_,n.concat(l))):h(p,_)||(o.length>s.length?("#text"===p.nodeName?c.push((new v).setValue(this.options._const.action,this.options._const.removeTextElement).setValue(this.options._const.route,n.concat(l)).setValue(this.options._const.value,p.data)):c.push((new v).setValue(this.options._const.action,this.options._const.removeElement).setValue(this.options._const.element,d(p)).setValue(this.options._const.route,n.concat(l))),o.splice(f,1),f-=1,l-=1,a-=1):o.length<s.length?(c=c.concat([(new v).setValue(this.options._const.action,this.options._const.addElement).setValue(this.options._const.element,d(_)).setValue(this.options._const.route,n.concat(l))]),o.splice(f,0,d(_)),a-=1):c=c.concat([(new v).setValue(this.options._const.action,this.options._const.replaceElement).setValue(this.options._const.oldValue,d(p)).setValue(this.options._const.newValue,d(_)).setValue(this.options._const.route,n.concat(l))]))),l+=1}return e.innerDone=!0,c},e.prototype.attemptGroupRelocation=function(e,t,n,o,s){for(var i,a,c,l,r,u=function(e,t,n){var o=e.childNodes?p(e.childNodes.length,!0):[],s=t.childNodes?p(t.childNodes.length,!0):[],i=0;return n.forEach((function(e){for(var t=e.oldValue+e.length,n=e.newValue+e.length,a=e.oldValue;a<t;a+=1)o[a]=i;for(a=e.newValue;a<n;a+=1)s[a]=i;i+=1})),{gaps1:o,gaps2:s}}(e,t,n),h=u.gaps1,m=u.gaps2,_=e.childNodes.slice(),V=t.childNodes.slice(),g=Math.min(h.length,m.length),b=[],N=0,y=0;N<g;y+=1,N+=1)if(!s||!0!==h[N]&&!0!==m[N]){if(!0===h[y])if("#text"===(l=_[y]).nodeName)if("#text"===V[N].nodeName){if(l.data!==V[N].data){for(var w=y;_.length>w+1&&"#text"===_[w+1].nodeName;)if(w+=1,V[N].data===_[w].data){r=!0;break}r||b.push((new v).setValue(this.options._const.action,this.options._const.modifyTextElement).setValue(this.options._const.route,o.concat(y)).setValue(this.options._const.oldValue,l.data).setValue(this.options._const.newValue,V[N].data))}}else b.push((new v).setValue(this.options._const.action,this.options._const.removeTextElement).setValue(this.options._const.route,o.concat(y)).setValue(this.options._const.value,l.data)),h.splice(y,1),_.splice(y,1),g=Math.min(h.length,m.length),y-=1,N-=1;else!0===m[N]?b.push((new v).setValue(this.options._const.action,this.options._const.replaceElement).setValue(this.options._const.oldValue,d(l)).setValue(this.options._const.newValue,d(V[N])).setValue(this.options._const.route,o.concat(y))):(b.push((new v).setValue(this.options._const.action,this.options._const.removeElement).setValue(this.options._const.route,o.concat(y)).setValue(this.options._const.element,d(l))),h.splice(y,1),_.splice(y,1),g=Math.min(h.length,m.length),y-=1,N-=1);else if(!0===m[N])"#text"===(l=V[N]).nodeName?(b.push((new v).setValue(this.options._const.action,this.options._const.addTextElement).setValue(this.options._const.route,o.concat(y)).setValue(this.options._const.value,l.data)),h.splice(y,0,!0),_.splice(y,0,{nodeName:"#text",data:l.data}),g=Math.min(h.length,m.length)):(b.push((new v).setValue(this.options._const.action,this.options._const.addElement).setValue(this.options._const.route,o.concat(y)).setValue(this.options._const.element,d(l))),h.splice(y,0,!0),_.splice(y,0,d(l)),g=Math.min(h.length,m.length));else if(h[y]!==m[N]){if(b.length>0)return b;if(c=n[h[y]],(a=Math.min(c.newValue,_.length-c.length))!==c.oldValue){i=!1;for(var E=0;E<c.length;E+=1)f(_[a+E],_[c.oldValue+E],{},!1,!0)||(i=!0);if(i)return[(new v).setValue(this.options._const.action,this.options._const.relocateGroup).setValue(this.options._const.groupLength,c.length).setValue(this.options._const.from,c.oldValue).setValue(this.options._const.to,a).setValue(this.options._const.route,o)]}}}else;return b},e.prototype.findValueDiff=function(e,t,n){var o=[];return e.selected!==t.selected&&o.push((new v).setValue(this.options._const.action,this.options._const.modifySelected).setValue(this.options._const.oldValue,e.selected).setValue(this.options._const.newValue,t.selected).setValue(this.options._const.route,n)),(e.value||t.value)&&e.value!==t.value&&"OPTION"!==e.nodeName&&o.push((new v).setValue(this.options._const.action,this.options._const.modifyValue).setValue(this.options._const.oldValue,e.value||"").setValue(this.options._const.newValue,t.value||"").setValue(this.options._const.route,n)),e.checked!==t.checked&&o.push((new v).setValue(this.options._const.action,this.options._const.modifyChecked).setValue(this.options._const.oldValue,e.checked).setValue(this.options._const.newValue,t.checked).setValue(this.options._const.route,n)),o},e}(),O={debug:!1,diffcap:10,maxDepth:!1,maxChildCount:50,valueDiffing:!0,textDiff:function(e,t,n,o){e.data=o},preVirtualDiffApply:function(){},postVirtualDiffApply:function(){},preDiffApply:function(){},postDiffApply:function(){},filterOuterDiff:null,compress:!1,_const:!1,document:!("undefined"==typeof window||!window.document)&&window.document,components:[]},A=function(){function e(e){if(void 0===e&&(e={}),Object.entries(O).forEach((function(t){var n=t[0],o=t[1];Object.prototype.hasOwnProperty.call(e,n)||(e[n]=o)})),!e._const){var t=["addAttribute","modifyAttribute","removeAttribute","modifyTextElement","relocateGroup","removeElement","addElement","removeTextElement","addTextElement","replaceElement","modifyValue","modifyChecked","modifySelected","modifyComment","action","route","oldValue","newValue","element","group","groupLength","from","to","name","value","data","attributes","nodeName","childNodes","checked","selected"],n={};e.compress?t.forEach((function(e,t){return n[e]=t})):t.forEach((function(e){return n[e]=e})),e._const=n}this.options=e}return e.prototype.apply=function(e,t){return function(e,t,n){return t.every((function(t){return o(e,t,n)}))}(e,t,this.options)},e.prototype.undo=function(e,t){return i(e,t,this.options)},e.prototype.diff=function(e,t){return new T(e,t,this.options).init()},e}(),D=function(){function e(e){void 0===e&&(e={});var t=this;this.pad="│ ",this.padding="",this.tick=1,this.messages=[];var n=function(e,n){var o=e[n];e[n]=function(){for(var s=arguments,i=[],a=0;a<arguments.length;a++)i[a]=s[a];t.fin(n,Array.prototype.slice.call(i));var c=o.apply(e,i);return t.fout(n,c),c}};for(var o in e)"function"==typeof e[o]&&n(e,o);this.log("┌ TRACELOG START")}return e.prototype.fin=function(e,t){this.padding+=this.pad,this.log("├─> entering ".concat(e),t)},e.prototype.fout=function(e,t){this.log("│<──┘ generated return value",t),this.padding=this.padding.substring(0,this.padding.length-this.pad.length)},e.prototype.format=function(e,t){return"".concat(function(e){for(var t="".concat(e);t.length<4;)t="0".concat(e);return t}(t),"> ").concat(this.padding).concat(e)},e.prototype.log=function(){for(var e=arguments,t=[],n=0;n<arguments.length;n++)t[n]=e[n];var o=function(e){return e?"string"==typeof e?e:e instanceof HTMLElement?e.outerHTML||"<empty>":e instanceof Array?"[".concat(e.map(o).join(","),"]"):e.toString()||e.valueOf()||"<unknown>":"<falsey>"},s=t.map(o).join(", ");this.messages.push(this.format(s,this.tick++))},e.prototype.toString=function(){for(var e="└───";e.length<=this.padding.length+this.pad.length;)e+="× ";var t=this.padding;return this.padding="",e=this.format(e,this.tick),this.padding=t,"".concat(this.messages.join("\n"),"\n").concat(e)},e}();return e.DiffDOM=A,e.TraceLogger=D,e.nodeToObj=b,e.stringToObj=x,e}({});
var diffDOM=function(e){"use strict";var t=function(){function e(e){var t=this;void 0===e&&(e={}),Object.entries(e).forEach((function(e){var n=e[0],o=e[1];return t[n]=o}))}return e.prototype.toString=function(){return JSON.stringify(this)},e.prototype.setValue=function(e,t){return this[e]=t,this},e}(),n=function(e){for(var t,n=arguments,o=[],s=1;s<arguments.length;s++)o[s-1]=n[s];if(null==e)return!1;var i=global||(null===(t=null==e?void 0:e.ownerDocument)||void 0===t?void 0:t.defaultView)||window;return o.some((function(t){return"function"==typeof(null==i?void 0:i[t])&&e instanceof i[t]}))};function o(e,t,s){var i;return"#text"===e.nodeName?i=s.document.createTextNode(e.data):"#comment"===e.nodeName?i=s.document.createComment(e.data):(t?i=s.document.createElementNS("http://www.w3.org/2000/svg",e.nodeName):"svg"===e.nodeName.toLowerCase()?(i=s.document.createElementNS("http://www.w3.org/2000/svg","svg"),t=!0):i=s.document.createElement(e.nodeName),e.attributes&&Object.entries(e.attributes).forEach((function(e){var t=e[0],n=e[1];return i.setAttribute(t,n)})),e.childNodes&&e.childNodes.forEach((function(e){return i.appendChild(o(e,t,s))})),s.valueDiffing&&(e.value&&n(i,"HTMLButtonElement","HTMLDataElement","HTMLInputElement","HTMLLIElement","HTMLMeterElement","HTMLOptionElement","HTMLProgressElement","HTMLParamElement")&&(i.value=e.value),e.checked&&n(i,"HTMLInputElement")&&(i.checked=e.checked),e.selected&&n(i,"HTMLOptionElement")&&(i.selected=e.selected))),i}var s=function(e,t){for(t=t.slice();t.length>0;){var n=t.splice(0,1)[0];e=e.childNodes[n]}return e};function i(e,t,i){var a,l,c,r=t[i._const.action],u=t[i._const.route];[i._const.addElement,i._const.addTextElement].includes(r)||(a=s(e,u));var d={diff:t,node:a};if(i.preDiffApply(d))return!0;switch(r){case i._const.addAttribute:if(!a||!n(a,"Element"))return!1;a.setAttribute(t[i._const.name],t[i._const.value]);break;case i._const.modifyAttribute:if(!a||!n(a,"Element"))return!1;a.setAttribute(t[i._const.name],t[i._const.newValue]),n(a,"HTMLInputElement")&&"value"===t[i._const.name]&&(a.value=t[i._const.newValue]);break;case i._const.removeAttribute:if(!a||!n(a,"Element"))return!1;a.removeAttribute(t[i._const.name]);break;case i._const.modifyTextElement:if(!a||!n(a,"Text"))return!1;i.textDiff(a,a.data,t[i._const.oldValue],t[i._const.newValue]),n(a.parentNode,"HTMLTextAreaElement")&&(a.parentNode.value=t[i._const.newValue]);break;case i._const.modifyValue:if(!a||void 0===a.value)return!1;a.value=t[i._const.newValue];break;case i._const.modifyComment:if(!a||!n(a,"Comment"))return!1;i.textDiff(a,a.data,t[i._const.oldValue],t[i._const.newValue]);break;case i._const.modifyChecked:if(!a||void 0===a.checked)return!1;a.checked=t[i._const.newValue];break;case i._const.modifySelected:if(!a||void 0===a.selected)return!1;a.selected=t[i._const.newValue];break;case i._const.replaceElement:var h="svg"===t[i._const.newValue].nodeName.toLowerCase()||"http://www.w3.org/2000/svg"===a.parentNode.namespaceURI;a.parentNode.replaceChild(o(t[i._const.newValue],h,i),a);break;case i._const.relocateGroup:Array.apply(void 0,new Array(t[i._const.groupLength])).map((function(){return a.removeChild(a.childNodes[t[i._const.from]])})).forEach((function(e,n){0===n&&(c=a.childNodes[t[i._const.to]]),a.insertBefore(e,c||null)}));break;case i._const.removeElement:a.parentNode.removeChild(a);break;case i._const.addElement:var p=(m=u.slice()).splice(m.length-1,1)[0];if(a=s(e,m),!n(a,"Element"))return!1;a.insertBefore(o(t[i._const.element],"http://www.w3.org/2000/svg"===a.namespaceURI,i),a.childNodes[p]||null);break;case i._const.removeTextElement:if(!a||3!==a.nodeType)return!1;var f=a.parentNode;f.removeChild(a),n(f,"HTMLTextAreaElement")&&(f.value="");break;case i._const.addTextElement:var m;p=(m=u.slice()).splice(m.length-1,1)[0];if(l=i.document.createTextNode(t[i._const.value]),!(a=s(e,m)).childNodes)return!1;a.insertBefore(l,a.childNodes[p]||null),n(a.parentNode,"HTMLTextAreaElement")&&(a.parentNode.value=t[i._const.value]);break;default:console.log("unknown action")}return i.postDiffApply({diff:d.diff,node:d.node,newNode:l}),!0}function a(e,t,n){var o=e[t];e[t]=e[n],e[n]=o}function l(e,t,n){(t=t.slice()).reverse(),t.forEach((function(t){!function(e,t,n){switch(t[n._const.action]){case n._const.addAttribute:t[n._const.action]=n._const.removeAttribute,i(e,t,n);break;case n._const.modifyAttribute:a(t,n._const.oldValue,n._const.newValue),i(e,t,n);break;case n._const.removeAttribute:t[n._const.action]=n._const.addAttribute,i(e,t,n);break;case n._const.modifyTextElement:case n._const.modifyValue:case n._const.modifyComment:case n._const.modifyChecked:case n._const.modifySelected:case n._const.replaceElement:a(t,n._const.oldValue,n._const.newValue),i(e,t,n);break;case n._const.relocateGroup:a(t,n._const.from,n._const.to),i(e,t,n);break;case n._const.removeElement:t[n._const.action]=n._const.addElement,i(e,t,n);break;case n._const.addElement:t[n._const.action]=n._const.removeElement,i(e,t,n);break;case n._const.removeTextElement:t[n._const.action]=n._const.addTextElement,i(e,t,n);break;case n._const.addTextElement:t[n._const.action]=n._const.removeTextElement,i(e,t,n);break;default:console.log("unknown action")}}(e,t,n)}))}var c=function(){return c=Object.assign||function(e){for(var t,n=arguments,o=1,s=arguments.length;o<s;o++)for(var i in t=n[o])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},c.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var r=function(e){var t=[];return t.push(e.nodeName),"#text"!==e.nodeName&&"#comment"!==e.nodeName&&e.attributes&&(e.attributes.class&&t.push("".concat(e.nodeName,".").concat(e.attributes.class.replace(/ /g,"."))),e.attributes.id&&t.push("".concat(e.nodeName,"#").concat(e.attributes.id))),t},u=function(e){var t={},n={};return e.forEach((function(e){r(e).forEach((function(e){var o=e in t;o||e in n?o&&(delete t[e],n[e]=!0):t[e]=!0}))})),t},d=function(e,t){var n=u(e),o=u(t),s={};return Object.keys(n).forEach((function(e){o[e]&&(s[e]=!0)})),s},h=function(e){return delete e.outerDone,delete e.innerDone,delete e.valueDone,!e.childNodes||e.childNodes.every(h)},p=function(e){if(Object.prototype.hasOwnProperty.call(e,"data"))return{nodeName:"#text"===e.nodeName?"#text":"#comment",data:e.data};var t={nodeName:e.nodeName};return Object.prototype.hasOwnProperty.call(e,"attributes")&&(t.attributes=c({},e.attributes)),Object.prototype.hasOwnProperty.call(e,"checked")&&(t.checked=e.checked),Object.prototype.hasOwnProperty.call(e,"value")&&(t.value=e.value),Object.prototype.hasOwnProperty.call(e,"selected")&&(t.selected=e.selected),Object.prototype.hasOwnProperty.call(e,"childNodes")&&(t.childNodes=e.childNodes.map((function(e){return p(e)}))),t},f=function(e,t){if(!["nodeName","value","checked","selected","data"].every((function(n){return e[n]===t[n]})))return!1;if(Object.prototype.hasOwnProperty.call(e,"data"))return!0;if(Boolean(e.attributes)!==Boolean(t.attributes))return!1;if(Boolean(e.childNodes)!==Boolean(t.childNodes))return!1;if(e.attributes){var n=Object.keys(e.attributes),o=Object.keys(t.attributes);if(n.length!==o.length)return!1;if(!n.every((function(n){return e.attributes[n]===t.attributes[n]})))return!1}if(e.childNodes){if(e.childNodes.length!==t.childNodes.length)return!1;if(!e.childNodes.every((function(e,n){return f(e,t.childNodes[n])})))return!1}return!0},m=function(e,t,n,o,s){if(void 0===s&&(s=!1),!e||!t)return!1;if(e.nodeName!==t.nodeName)return!1;if(["#text","#comment"].includes(e.nodeName))return!!s||e.data===t.data;if(e.nodeName in n)return!0;if(e.attributes&&t.attributes){if(e.attributes.id){if(e.attributes.id!==t.attributes.id)return!1;if("".concat(e.nodeName,"#").concat(e.attributes.id)in n)return!0}if(e.attributes.class&&e.attributes.class===t.attributes.class)if("".concat(e.nodeName,".").concat(e.attributes.class.replace(/ /g,"."))in n)return!0}if(o)return!0;var i=e.childNodes?e.childNodes.slice().reverse():[],a=t.childNodes?t.childNodes.slice().reverse():[];if(i.length!==a.length)return!1;if(s)return i.every((function(e,t){return e.nodeName===a[t].nodeName}));var l=d(i,a);return i.every((function(e,t){return m(e,a[t],l,!0,!0)}))},_=function(e,t){return Array.apply(void 0,new Array(e)).map((function(){return t}))},v=function(e,t){for(var n=e.childNodes?e.childNodes:[],o=t.childNodes?t.childNodes:[],s=_(n.length,!1),i=_(o.length,!1),a=[],l=function(){return arguments[1]},c=!1,u=function(){var e=function(e,t,n,o){var s=0,i=[],a=e.length,l=t.length,c=Array.apply(void 0,new Array(a+1)).map((function(){return[]})),u=d(e,t),h=a===l;h&&e.some((function(e,n){var o=r(e),s=r(t[n]);return o.length!==s.length?(h=!1,!0):(o.some((function(e,t){if(e!==s[t])return h=!1,!0})),!h||void 0)}));for(var p=0;p<a;p++)for(var f=e[p],_=0;_<l;_++){var v=t[_];n[p]||o[_]||!m(f,v,u,h)?c[p+1][_+1]=0:(c[p+1][_+1]=c[p][_]?c[p][_]+1:1,c[p+1][_+1]>=s&&(s=c[p+1][_+1],i=[p+1,_+1]))}return 0!==s&&{oldValue:i[0]-s,newValue:i[1]-s,length:s}}(n,o,s,i);e?(a.push(e),Array.apply(void 0,new Array(e.length)).map(l).forEach((function(t){return function(e,t,n,o){e[n.oldValue+o]=!0,t[n.newValue+o]=!0}(s,i,e,t)}))):c=!0};!c;)u();return e.subsets=a,e.subsetsAge=100,a},g=function(){function e(){this.list=[]}return e.prototype.add=function(e){var t;(t=this.list).push.apply(t,e)},e.prototype.forEach=function(e){this.list.forEach((function(t){return e(t)}))},e}();function V(e,t){var n,o,s=e;for(t=t.slice();t.length>0;)o=t.splice(0,1)[0],n=s,s=s.childNodes?s.childNodes[o]:void 0;return{node:s,parentNode:n,nodeIndex:o}}function b(e,t,n){return t.forEach((function(t){!function(e,t,n){var o,s,i,a;if(![n._const.addElement,n._const.addTextElement].includes(t[n._const.action])){var l=V(e,t[n._const.route]);s=l.node,i=l.parentNode,a=l.nodeIndex}var c,r,u=[],d={diff:t,node:s};if(n.preVirtualDiffApply(d))return!0;switch(t[n._const.action]){case n._const.addAttribute:s.attributes||(s.attributes={}),s.attributes[t[n._const.name]]=t[n._const.value],"checked"===t[n._const.name]?s.checked=!0:"selected"===t[n._const.name]?s.selected=!0:"INPUT"===s.nodeName&&"value"===t[n._const.name]&&(s.value=t[n._const.value]);break;case n._const.modifyAttribute:s.attributes[t[n._const.name]]=t[n._const.newValue];break;case n._const.removeAttribute:delete s.attributes[t[n._const.name]],0===Object.keys(s.attributes).length&&delete s.attributes,"checked"===t[n._const.name]?s.checked=!1:"selected"===t[n._const.name]?delete s.selected:"INPUT"===s.nodeName&&"value"===t[n._const.name]&&delete s.value;break;case n._const.modifyTextElement:s.data=t[n._const.newValue],"TEXTAREA"===i.nodeName&&(i.value=t[n._const.newValue]);break;case n._const.modifyValue:s.value=t[n._const.newValue];break;case n._const.modifyComment:s.data=t[n._const.newValue];break;case n._const.modifyChecked:s.checked=t[n._const.newValue];break;case n._const.modifySelected:s.selected=t[n._const.newValue];break;case n._const.replaceElement:c=p(t[n._const.newValue]),i.childNodes[a]=c;break;case n._const.relocateGroup:s.childNodes.splice(t[n._const.from],t[n._const.groupLength]).reverse().forEach((function(e){return s.childNodes.splice(t[n._const.to],0,e)})),s.subsets&&s.subsets.forEach((function(e){if(t[n._const.from]<t[n._const.to]&&e.oldValue<=t[n._const.to]&&e.oldValue>t[n._const.from])e.oldValue-=t[n._const.groupLength],(o=e.oldValue+e.length-t[n._const.to])>0&&(u.push({oldValue:t[n._const.to]+t[n._const.groupLength],newValue:e.newValue+e.length-o,length:o}),e.length-=o);else if(t[n._const.from]>t[n._const.to]&&e.oldValue>t[n._const.to]&&e.oldValue<t[n._const.from]){var o;e.oldValue+=t[n._const.groupLength],(o=e.oldValue+e.length-t[n._const.to])>0&&(u.push({oldValue:t[n._const.to]+t[n._const.groupLength],newValue:e.newValue+e.length-o,length:o}),e.length-=o)}else e.oldValue===t[n._const.from]&&(e.oldValue=t[n._const.to])}));break;case n._const.removeElement:i.childNodes.splice(a,1),i.subsets&&i.subsets.forEach((function(e){e.oldValue>a?e.oldValue-=1:e.oldValue===a?e.delete=!0:e.oldValue<a&&e.oldValue+e.length>a&&(e.oldValue+e.length-1===a?e.length--:(u.push({newValue:e.newValue+a-e.oldValue,oldValue:a,length:e.length-a+e.oldValue-1}),e.length=a-e.oldValue))})),s=i;break;case n._const.addElement:var h=(r=t[n._const.route].slice()).splice(r.length-1,1)[0];s=null===(o=V(e,r))||void 0===o?void 0:o.node,c=p(t[n._const.element]),s.childNodes||(s.childNodes=[]),h>=s.childNodes.length?s.childNodes.push(c):s.childNodes.splice(h,0,c),s.subsets&&s.subsets.forEach((function(e){if(e.oldValue>=h)e.oldValue+=1;else if(e.oldValue<h&&e.oldValue+e.length>h){var t=e.oldValue+e.length-h;u.push({newValue:e.newValue+e.length-t,oldValue:h+1,length:t}),e.length-=t}}));break;case n._const.removeTextElement:i.childNodes.splice(a,1),"TEXTAREA"===i.nodeName&&delete i.value,i.subsets&&i.subsets.forEach((function(e){e.oldValue>a?e.oldValue-=1:e.oldValue===a?e.delete=!0:e.oldValue<a&&e.oldValue+e.length>a&&(e.oldValue+e.length-1===a?e.length--:(u.push({newValue:e.newValue+a-e.oldValue,oldValue:a,length:e.length-a+e.oldValue-1}),e.length=a-e.oldValue))})),s=i;break;case n._const.addTextElement:var f=(r=t[n._const.route].slice()).splice(r.length-1,1)[0];c={nodeName:"#text",data:t[n._const.value]},(s=V(e,r).node).childNodes||(s.childNodes=[]),f>=s.childNodes.length?s.childNodes.push(c):s.childNodes.splice(f,0,c),"TEXTAREA"===s.nodeName&&(s.value=t[n._const.newValue]),s.subsets&&s.subsets.forEach((function(e){if(e.oldValue>=f&&(e.oldValue+=1),e.oldValue<f&&e.oldValue+e.length>f){var t=e.oldValue+e.length-f;u.push({newValue:e.newValue+e.length-t,oldValue:f+1,length:t}),e.length-=t}}));break;default:console.log("unknown action")}s.subsets&&(s.subsets=s.subsets.filter((function(e){return!e.delete&&e.oldValue!==e.newValue})),u.length&&(s.subsets=s.subsets.concat(u))),n.postVirtualDiffApply({node:d.node,diff:d.diff,newNode:c})}(e,t,n)})),!0}function N(e,t){void 0===t&&(t={valueDiffing:!0});var o={nodeName:e.nodeName};if(n(e,"Text","Comment"))o.data=e.data;else{if(e.attributes&&e.attributes.length>0)o.attributes={},Array.prototype.slice.call(e.attributes).forEach((function(e){return o.attributes[e.name]=e.value}));if(e.childNodes&&e.childNodes.length>0)o.childNodes=[],Array.prototype.slice.call(e.childNodes).forEach((function(e){return o.childNodes.push(N(e,t))}));t.valueDiffing&&(n(e,"HTMLTextAreaElement")&&(o.value=e.value),n(e,"HTMLInputElement")&&["radio","checkbox"].includes(e.type.toLowerCase())&&void 0!==e.checked?o.checked=e.checked:n(e,"HTMLButtonElement","HTMLDataElement","HTMLInputElement","HTMLLIElement","HTMLMeterElement","HTMLOptionElement","HTMLProgressElement","HTMLParamElement")&&(o.value=e.value),n(e,"HTMLOptionElement")&&(o.selected=e.selected))}return o}var y=/<\s*\/*[a-zA-Z:_][a-zA-Z0-9:_\-.]*\s*(?:"[^"]*"['"]*|'[^']*'['"]*|[^'"/>])*\/*\s*>|<!--(?:.|\n|\r)*?-->/g,w=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function E(e){return e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&")}var k={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,menuItem:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},x=function(e,t){var n={nodeName:"",attributes:{}},o=!1,s=e.match(/<\/?([^\s]+?)[/\s>]/);if(s&&(n.nodeName=t||"svg"===s[1]?s[1]:s[1].toUpperCase(),(k[s[1]]||"/"===e.charAt(e.length-2))&&(o=!0),n.nodeName.startsWith("!--"))){var i=e.indexOf("--\x3e");return{type:"comment",node:{nodeName:"#comment",data:-1!==i?e.slice(4,i):""},voidElement:o}}for(var a=new RegExp(w),l=null,c=!1;!c;)if(null===(l=a.exec(e)))c=!0;else if(l[0].trim())if(l[1]){var r=l[1].trim(),u=[r,""];r.indexOf("=")>-1&&(u=r.split("=")),n.attributes[u[0]]=u[1],a.lastIndex--}else l[2]&&(n.attributes[l[2]]=l[3].trim().substring(1,l[3].length-1));return{type:"tag",node:n,voidElement:o}},T=function(e,t){void 0===t&&(t={valueDiffing:!0,caseSensitive:!1});var n,o=[],s=-1,i=[],a=!1;if(0!==e.indexOf("<")){var l=e.indexOf("<");o.push({nodeName:"#text",data:-1===l?e:e.substring(0,l)})}return e.replace(y,(function(l,c){var r="/"!==l.charAt(1),u=l.startsWith("\x3c!--"),d=c+l.length,h=e.charAt(d);if(u){var p=x(l,t.caseSensitive).node;if(s<0)return o.push(p),"";var f=i[s];return f&&p.nodeName&&(f.node.childNodes||(f.node.childNodes=[]),f.node.childNodes.push(p)),""}if(r){if("svg"===(n=x(l,t.caseSensitive||a)).node.nodeName&&(a=!0),s++,!n.voidElement&&h&&"<"!==h){n.node.childNodes||(n.node.childNodes=[]);var m=E(e.slice(d,e.indexOf("<",d)));n.node.childNodes.push({nodeName:"#text",data:m}),t.valueDiffing&&"TEXTAREA"===n.node.nodeName&&(n.node.value=m)}0===s&&n.node.nodeName&&o.push(n.node);var _=i[s-1];_&&n.node.nodeName&&(_.node.childNodes||(_.node.childNodes=[]),_.node.childNodes.push(n.node)),i[s]=n}if((!r||n.voidElement)&&(s>-1&&(n.voidElement||t.caseSensitive&&n.node.nodeName===l.slice(2,-1)||!t.caseSensitive&&n.node.nodeName.toUpperCase()===l.slice(2,-1).toUpperCase())&&--s>-1&&("svg"===n.node.nodeName&&(a=!1),n=i[s]),"<"!==h&&h)){var v=-1===s?o:i[s].node.childNodes||[],g=e.indexOf("<",d);m=E(e.slice(d,-1===g?void 0:g));v.push({nodeName:"#text",data:m})}return""})),o[0]},O=function(){function e(e,t,o){this.options=o,this.t1="undefined"!=typeof Element&&n(e,"Element")?N(e,this.options):"string"==typeof e?T(e,this.options):JSON.parse(JSON.stringify(e)),this.t2="undefined"!=typeof Element&&n(t,"Element")?N(t,this.options):"string"==typeof t?T(t,this.options):JSON.parse(JSON.stringify(t)),this.diffcount=0,this.foundAll=!1,this.debug&&(this.t1Orig="undefined"!=typeof Element&&n(e,"Element")?N(e,this.options):"string"==typeof e?T(e,this.options):JSON.parse(JSON.stringify(e)),this.t2Orig="undefined"!=typeof Element&&n(t,"Element")?N(t,this.options):"string"==typeof t?T(t,this.options):JSON.parse(JSON.stringify(t))),this.tracker=new g}return e.prototype.init=function(){return this.findDiffs(this.t1,this.t2)},e.prototype.findDiffs=function(e,t){var n;do{if(this.options.debug&&(this.diffcount+=1,this.diffcount>this.options.diffcap))throw new Error("surpassed diffcap:".concat(JSON.stringify(this.t1Orig)," -> ").concat(JSON.stringify(this.t2Orig)));0===(n=this.findNextDiff(e,t,[])).length&&(f(e,t)||(this.foundAll?console.error("Could not find remaining diffs!"):(this.foundAll=!0,h(e),n=this.findNextDiff(e,t,[])))),n.length>0&&(this.foundAll=!1,this.tracker.add(n),b(e,n,this.options))}while(n.length>0);return this.tracker.list},e.prototype.findNextDiff=function(e,t,n){var o,s;if(this.options.maxDepth&&n.length>this.options.maxDepth)return[];if(!e.outerDone){if(o=this.findOuterDiff(e,t,n),this.options.filterOuterDiff&&(s=this.options.filterOuterDiff(e,t,o))&&(o=s),o.length>0)return e.outerDone=!0,o;e.outerDone=!0}if(Object.prototype.hasOwnProperty.call(e,"data"))return[];if(!e.innerDone){if((o=this.findInnerDiff(e,t,n)).length>0)return o;e.innerDone=!0}if(this.options.valueDiffing&&!e.valueDone){if((o=this.findValueDiff(e,t,n)).length>0)return e.valueDone=!0,o;e.valueDone=!0}return[]},e.prototype.findOuterDiff=function(e,n,o){var s,i,a,l,c,r,u=[];if(e.nodeName!==n.nodeName){if(!o.length)throw new Error("Top level nodes have to be of the same kind.");return[(new t).setValue(this.options._const.action,this.options._const.replaceElement).setValue(this.options._const.oldValue,p(e)).setValue(this.options._const.newValue,p(n)).setValue(this.options._const.route,o)]}if(o.length&&this.options.diffcap<Math.abs((e.childNodes||[]).length-(n.childNodes||[]).length))return[(new t).setValue(this.options._const.action,this.options._const.replaceElement).setValue(this.options._const.oldValue,p(e)).setValue(this.options._const.newValue,p(n)).setValue(this.options._const.route,o)];if(Object.prototype.hasOwnProperty.call(e,"data")&&e.data!==n.data)return"#text"===e.nodeName?[(new t).setValue(this.options._const.action,this.options._const.modifyTextElement).setValue(this.options._const.route,o).setValue(this.options._const.oldValue,e.data).setValue(this.options._const.newValue,n.data)]:[(new t).setValue(this.options._const.action,this.options._const.modifyComment).setValue(this.options._const.route,o).setValue(this.options._const.oldValue,e.data).setValue(this.options._const.newValue,n.data)];for(i=e.attributes?Object.keys(e.attributes).sort():[],a=n.attributes?Object.keys(n.attributes).sort():[],l=i.length,r=0;r<l;r++)s=i[r],-1===(c=a.indexOf(s))?u.push((new t).setValue(this.options._const.action,this.options._const.removeAttribute).setValue(this.options._const.route,o).setValue(this.options._const.name,s).setValue(this.options._const.value,e.attributes[s])):(a.splice(c,1),e.attributes[s]!==n.attributes[s]&&u.push((new t).setValue(this.options._const.action,this.options._const.modifyAttribute).setValue(this.options._const.route,o).setValue(this.options._const.name,s).setValue(this.options._const.oldValue,e.attributes[s]).setValue(this.options._const.newValue,n.attributes[s])));for(l=a.length,r=0;r<l;r++)s=a[r],u.push((new t).setValue(this.options._const.action,this.options._const.addAttribute).setValue(this.options._const.route,o).setValue(this.options._const.name,s).setValue(this.options._const.value,n.attributes[s]));return u},e.prototype.findInnerDiff=function(e,n,o){var s=e.childNodes?e.childNodes.slice():[],i=n.childNodes?n.childNodes.slice():[],a=Math.max(s.length,i.length),l=Math.abs(s.length-i.length),c=[],r=0;if(!this.options.maxChildCount||a<this.options.maxChildCount){var u=Boolean(e.subsets&&e.subsetsAge--),d=u?e.subsets:e.childNodes&&n.childNodes?v(e,n):[];if(d.length>0&&(c=this.attemptGroupRelocation(e,n,d,o,u)).length>0)return c}for(var h=0;h<a;h+=1){var m=s[h],_=i[h];l&&(m&&!_?"#text"===m.nodeName?(c.push((new t).setValue(this.options._const.action,this.options._const.removeTextElement).setValue(this.options._const.route,o.concat(r)).setValue(this.options._const.value,m.data)),r-=1):(c.push((new t).setValue(this.options._const.action,this.options._const.removeElement).setValue(this.options._const.route,o.concat(r)).setValue(this.options._const.element,p(m))),r-=1):_&&!m&&("#text"===_.nodeName?c.push((new t).setValue(this.options._const.action,this.options._const.addTextElement).setValue(this.options._const.route,o.concat(r)).setValue(this.options._const.value,_.data)):c.push((new t).setValue(this.options._const.action,this.options._const.addElement).setValue(this.options._const.route,o.concat(r)).setValue(this.options._const.element,p(_))))),m&&_&&(!this.options.maxChildCount||a<this.options.maxChildCount?c=c.concat(this.findNextDiff(m,_,o.concat(r))):f(m,_)||(s.length>i.length?("#text"===m.nodeName?c.push((new t).setValue(this.options._const.action,this.options._const.removeTextElement).setValue(this.options._const.route,o.concat(r)).setValue(this.options._const.value,m.data)):c.push((new t).setValue(this.options._const.action,this.options._const.removeElement).setValue(this.options._const.element,p(m)).setValue(this.options._const.route,o.concat(r))),s.splice(h,1),h-=1,r-=1,l-=1):s.length<i.length?(c=c.concat([(new t).setValue(this.options._const.action,this.options._const.addElement).setValue(this.options._const.element,p(_)).setValue(this.options._const.route,o.concat(r))]),s.splice(h,0,p(_)),l-=1):c=c.concat([(new t).setValue(this.options._const.action,this.options._const.replaceElement).setValue(this.options._const.oldValue,p(m)).setValue(this.options._const.newValue,p(_)).setValue(this.options._const.route,o.concat(r))]))),r+=1}return e.innerDone=!0,c},e.prototype.attemptGroupRelocation=function(e,n,o,s,i){for(var a,l,c,r,u,d=function(e,t,n){var o=e.childNodes?_(e.childNodes.length,!0):[],s=t.childNodes?_(t.childNodes.length,!0):[],i=0;return n.forEach((function(e){for(var t=e.oldValue+e.length,n=e.newValue+e.length,a=e.oldValue;a<t;a+=1)o[a]=i;for(a=e.newValue;a<n;a+=1)s[a]=i;i+=1})),{gaps1:o,gaps2:s}}(e,n,o),h=d.gaps1,f=d.gaps2,v=e.childNodes.slice(),g=n.childNodes.slice(),V=Math.min(h.length,f.length),b=[],N=0,y=0;N<V;y+=1,N+=1)if(!i||!0!==h[N]&&!0!==f[N]){if(!0===h[y])if("#text"===(r=v[y]).nodeName)if("#text"===g[N].nodeName){if(r.data!==g[N].data){for(var w=y;v.length>w+1&&"#text"===v[w+1].nodeName;)if(w+=1,g[N].data===v[w].data){u=!0;break}u||b.push((new t).setValue(this.options._const.action,this.options._const.modifyTextElement).setValue(this.options._const.route,s.concat(y)).setValue(this.options._const.oldValue,r.data).setValue(this.options._const.newValue,g[N].data))}}else b.push((new t).setValue(this.options._const.action,this.options._const.removeTextElement).setValue(this.options._const.route,s.concat(y)).setValue(this.options._const.value,r.data)),h.splice(y,1),v.splice(y,1),V=Math.min(h.length,f.length),y-=1,N-=1;else!0===f[N]?b.push((new t).setValue(this.options._const.action,this.options._const.replaceElement).setValue(this.options._const.oldValue,p(r)).setValue(this.options._const.newValue,p(g[N])).setValue(this.options._const.route,s.concat(y))):(b.push((new t).setValue(this.options._const.action,this.options._const.removeElement).setValue(this.options._const.route,s.concat(y)).setValue(this.options._const.element,p(r))),h.splice(y,1),v.splice(y,1),V=Math.min(h.length,f.length),y-=1,N-=1);else if(!0===f[N])"#text"===(r=g[N]).nodeName?(b.push((new t).setValue(this.options._const.action,this.options._const.addTextElement).setValue(this.options._const.route,s.concat(y)).setValue(this.options._const.value,r.data)),h.splice(y,0,!0),v.splice(y,0,{nodeName:"#text",data:r.data}),V=Math.min(h.length,f.length)):(b.push((new t).setValue(this.options._const.action,this.options._const.addElement).setValue(this.options._const.route,s.concat(y)).setValue(this.options._const.element,p(r))),h.splice(y,0,!0),v.splice(y,0,p(r)),V=Math.min(h.length,f.length));else if(h[y]!==f[N]){if(b.length>0)return b;if(c=o[h[y]],(l=Math.min(c.newValue,v.length-c.length))!==c.oldValue){a=!1;for(var E=0;E<c.length;E+=1)m(v[l+E],v[c.oldValue+E],{},!1,!0)||(a=!0);if(a)return[(new t).setValue(this.options._const.action,this.options._const.relocateGroup).setValue(this.options._const.groupLength,c.length).setValue(this.options._const.from,c.oldValue).setValue(this.options._const.to,l).setValue(this.options._const.route,s)]}}}else;return b},e.prototype.findValueDiff=function(e,n,o){var s=[];return e.selected!==n.selected&&s.push((new t).setValue(this.options._const.action,this.options._const.modifySelected).setValue(this.options._const.oldValue,e.selected).setValue(this.options._const.newValue,n.selected).setValue(this.options._const.route,o)),(e.value||n.value)&&e.value!==n.value&&"OPTION"!==e.nodeName&&s.push((new t).setValue(this.options._const.action,this.options._const.modifyValue).setValue(this.options._const.oldValue,e.value||"").setValue(this.options._const.newValue,n.value||"").setValue(this.options._const.route,o)),e.checked!==n.checked&&s.push((new t).setValue(this.options._const.action,this.options._const.modifyChecked).setValue(this.options._const.oldValue,e.checked).setValue(this.options._const.newValue,n.checked).setValue(this.options._const.route,o)),s},e}(),A={debug:!1,diffcap:10,maxDepth:!1,maxChildCount:50,valueDiffing:!0,textDiff:function(e,t,n,o){e.data=o},preVirtualDiffApply:function(){},postVirtualDiffApply:function(){},preDiffApply:function(){},postDiffApply:function(){},filterOuterDiff:null,compress:!1,_const:!1,document:!("undefined"==typeof window||!window.document)&&window.document,components:[]},D=function(){function e(e){if(void 0===e&&(e={}),Object.entries(A).forEach((function(t){var n=t[0],o=t[1];Object.prototype.hasOwnProperty.call(e,n)||(e[n]=o)})),!e._const){var t=["addAttribute","modifyAttribute","removeAttribute","modifyTextElement","relocateGroup","removeElement","addElement","removeTextElement","addTextElement","replaceElement","modifyValue","modifyChecked","modifySelected","modifyComment","action","route","oldValue","newValue","element","group","groupLength","from","to","name","value","data","attributes","nodeName","childNodes","checked","selected"],n={};e.compress?t.forEach((function(e,t){return n[e]=t})):t.forEach((function(e){return n[e]=e})),e._const=n}this.options=e}return e.prototype.apply=function(e,t){return function(e,t,n){return t.every((function(t){return i(e,t,n)}))}(e,t,this.options)},e.prototype.undo=function(e,t){return l(e,t,this.options)},e.prototype.diff=function(e,t){return new O(e,t,this.options).init()},e}(),L=function(){function e(e){var t=this;void 0===e&&(e={}),this.pad="│ ",this.padding="",this.tick=1,this.messages=[];var n=function(e,n){var o=e[n];e[n]=function(){for(var s=arguments,i=[],a=0;a<arguments.length;a++)i[a]=s[a];t.fin(n,Array.prototype.slice.call(i));var l=o.apply(e,i);return t.fout(n,l),l}};for(var o in e)"function"==typeof e[o]&&n(e,o);this.log("┌ TRACELOG START")}return e.prototype.fin=function(e,t){this.padding+=this.pad,this.log("├─> entering ".concat(e),t)},e.prototype.fout=function(e,t){this.log("│<──┘ generated return value",t),this.padding=this.padding.substring(0,this.padding.length-this.pad.length)},e.prototype.format=function(e,t){return"".concat(function(e){for(var t="".concat(e);t.length<4;)t="0".concat(e);return t}(t),"> ").concat(this.padding).concat(e)},e.prototype.log=function(){for(var e=arguments,t=[],o=0;o<arguments.length;o++)t[o]=e[o];var s=function(e){return e?"string"==typeof e?e:n(e,"HTMLElement")?e.outerHTML||"<empty>":e instanceof Array?"[".concat(e.map(s).join(","),"]"):e.toString()||e.valueOf()||"<unknown>":"<falsey>"},i=t.map(s).join(", ");this.messages.push(this.format(i,this.tick++))},e.prototype.toString=function(){for(var e="└───";e.length<=this.padding.length+this.pad.length;)e+="× ";var t=this.padding;return this.padding="",e=this.format(e,this.tick),this.padding=t,"".concat(this.messages.join("\n"),"\n").concat(e)},e}();return e.DiffDOM=D,e.TraceLogger=L,e.nodeToObj=N,e.stringToObj=T,e}({});
//# sourceMappingURL=diffDOM.js.map

@@ -11,1 +11,2 @@ import { elementNodeType } from "./types";

}
export declare const checkElementType: (element: any, ...elementTypeNames: string[]) => boolean;

@@ -1,2 +0,2 @@

"use strict";function e(t,n,o){var s;return"#text"===t.nodeName?s=o.document.createTextNode(t.data):"#comment"===t.nodeName?s=o.document.createComment(t.data):(n?s=o.document.createElementNS("http://www.w3.org/2000/svg",t.nodeName):"svg"===t.nodeName.toLowerCase()?(s=o.document.createElementNS("http://www.w3.org/2000/svg","svg"),n=!0):s=o.document.createElement(t.nodeName),t.attributes&&Object.entries(t.attributes).forEach((function(e){var t=e[0],n=e[1];return s.setAttribute(t,n)})),t.childNodes&&t.childNodes.forEach((function(t){return s.appendChild(e(t,n,o))})),o.valueDiffing&&(t.value&&(s instanceof HTMLButtonElement||s instanceof HTMLDataElement||s instanceof HTMLInputElement||s instanceof HTMLLIElement||s instanceof HTMLMeterElement||s instanceof HTMLOptionElement||s instanceof HTMLProgressElement||s instanceof HTMLParamElement)&&(s.value=t.value),t.checked&&s instanceof HTMLInputElement&&(s.checked=t.checked),t.selected&&s instanceof HTMLOptionElement&&(s.selected=t.selected))),s}var t=function(e,t){for(t=t.slice();t.length>0;){var n=t.splice(0,1)[0];e=e.childNodes[n]}return e};function n(n,o,s){var i,a,c,l=o[s._const.action],r=o[s._const.route];[s._const.addElement,s._const.addTextElement].includes(l)||(i=t(n,r));var u={diff:o,node:i};if(s.preDiffApply(u))return!0;switch(l){case s._const.addAttribute:if(!(i&&i instanceof Element))return!1;i.setAttribute(o[s._const.name],o[s._const.value]);break;case s._const.modifyAttribute:if(!(i&&i instanceof Element))return!1;i.setAttribute(o[s._const.name],o[s._const.newValue]),i instanceof HTMLInputElement&&"value"===o[s._const.name]&&(i.value=o[s._const.newValue]);break;case s._const.removeAttribute:if(!(i&&i instanceof Element))return!1;i.removeAttribute(o[s._const.name]);break;case s._const.modifyTextElement:if(!(i&&i instanceof Text))return!1;s.textDiff(i,i.data,o[s._const.oldValue],o[s._const.newValue]),i.parentNode instanceof HTMLTextAreaElement&&(i.parentNode.value=o[s._const.newValue]);break;case s._const.modifyValue:if(!i||void 0===i.value)return!1;i.value=o[s._const.newValue];break;case s._const.modifyComment:if(!(i&&i instanceof Comment))return!1;s.textDiff(i,i.data,o[s._const.oldValue],o[s._const.newValue]);break;case s._const.modifyChecked:if(!i||void 0===i.checked)return!1;i.checked=o[s._const.newValue];break;case s._const.modifySelected:if(!i||void 0===i.selected)return!1;i.selected=o[s._const.newValue];break;case s._const.replaceElement:var d="svg"===o[s._const.newValue].nodeName.toLowerCase()||"http://www.w3.org/2000/svg"===i.parentNode.namespaceURI;i.parentNode.replaceChild(e(o[s._const.newValue],d,s),i);break;case s._const.relocateGroup:Array.apply(void 0,new Array(o[s._const.groupLength])).map((function(){return i.removeChild(i.childNodes[o[s._const.from]])})).forEach((function(e,t){0===t&&(c=i.childNodes[o[s._const.to]]),i.insertBefore(e,c||null)}));break;case s._const.removeElement:i.parentNode.removeChild(i);break;case s._const.addElement:var h=(p=r.slice()).splice(p.length-1,1)[0];if(!((i=t(n,p))instanceof Element))return!1;i.insertBefore(e(o[s._const.element],"http://www.w3.org/2000/svg"===i.namespaceURI,s),i.childNodes[h]||null);break;case s._const.removeTextElement:if(!i||3!==i.nodeType)return!1;var f=i.parentNode;f.removeChild(i),f instanceof HTMLTextAreaElement&&(f.value="");break;case s._const.addTextElement:var p;h=(p=r.slice()).splice(p.length-1,1)[0];if(a=s.document.createTextNode(o[s._const.value]),!(i=t(n,p)).childNodes)return!1;i.insertBefore(a,i.childNodes[h]||null),i.parentNode instanceof HTMLTextAreaElement&&(i.parentNode.value=o[s._const.value]);break;default:console.log("unknown action")}return s.postDiffApply({diff:u.diff,node:u.node,newNode:a}),!0}function o(e,t,n){var o=e[t];e[t]=e[n],e[n]=o}function s(e,t,s){(t=t.slice()).reverse(),t.forEach((function(t){!function(e,t,s){switch(t[s._const.action]){case s._const.addAttribute:t[s._const.action]=s._const.removeAttribute,n(e,t,s);break;case s._const.modifyAttribute:o(t,s._const.oldValue,s._const.newValue),n(e,t,s);break;case s._const.removeAttribute:t[s._const.action]=s._const.addAttribute,n(e,t,s);break;case s._const.modifyTextElement:case s._const.modifyValue:case s._const.modifyComment:case s._const.modifyChecked:case s._const.modifySelected:case s._const.replaceElement:o(t,s._const.oldValue,s._const.newValue),n(e,t,s);break;case s._const.relocateGroup:o(t,s._const.from,s._const.to),n(e,t,s);break;case s._const.removeElement:t[s._const.action]=s._const.addElement,n(e,t,s);break;case s._const.addElement:t[s._const.action]=s._const.removeElement,n(e,t,s);break;case s._const.removeTextElement:t[s._const.action]=s._const.addTextElement,n(e,t,s);break;case s._const.addTextElement:t[s._const.action]=s._const.removeTextElement,n(e,t,s);break;default:console.log("unknown action")}}(e,t,s)}))}var i=function(){return i=Object.assign||function(e){for(var t,n=arguments,o=1,s=arguments.length;o<s;o++)for(var i in t=n[o])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},i.apply(this,arguments)},a=function(e){var t=[];return t.push(e.nodeName),"#text"!==e.nodeName&&"#comment"!==e.nodeName&&e.attributes&&(e.attributes.class&&t.push("".concat(e.nodeName,".").concat(e.attributes.class.replace(/ /g,"."))),e.attributes.id&&t.push("".concat(e.nodeName,"#").concat(e.attributes.id))),t},c=function(e){var t={},n={};return e.forEach((function(e){a(e).forEach((function(e){var o=e in t;o||e in n?o&&(delete t[e],n[e]=!0):t[e]=!0}))})),t},l=function(e,t){var n=c(e),o=c(t),s={};return Object.keys(n).forEach((function(e){o[e]&&(s[e]=!0)})),s},r=function(e){return delete e.outerDone,delete e.innerDone,delete e.valueDone,!e.childNodes||e.childNodes.every(r)},u=function(e){if(Object.prototype.hasOwnProperty.call(e,"data"))return{nodeName:"#text"===e.nodeName?"#text":"#comment",data:e.data};var t={nodeName:e.nodeName};return Object.prototype.hasOwnProperty.call(e,"attributes")&&(t.attributes=i({},e.attributes)),Object.prototype.hasOwnProperty.call(e,"checked")&&(t.checked=e.checked),Object.prototype.hasOwnProperty.call(e,"value")&&(t.value=e.value),Object.prototype.hasOwnProperty.call(e,"selected")&&(t.selected=e.selected),Object.prototype.hasOwnProperty.call(e,"childNodes")&&(t.childNodes=e.childNodes.map((function(e){return u(e)}))),t},d=function(e,t){if(!["nodeName","value","checked","selected","data"].every((function(n){return e[n]===t[n]})))return!1;if(Object.prototype.hasOwnProperty.call(e,"data"))return!0;if(Boolean(e.attributes)!==Boolean(t.attributes))return!1;if(Boolean(e.childNodes)!==Boolean(t.childNodes))return!1;if(e.attributes){var n=Object.keys(e.attributes),o=Object.keys(t.attributes);if(n.length!==o.length)return!1;if(!n.every((function(n){return e.attributes[n]===t.attributes[n]})))return!1}if(e.childNodes){if(e.childNodes.length!==t.childNodes.length)return!1;if(!e.childNodes.every((function(e,n){return d(e,t.childNodes[n])})))return!1}return!0},h=function(e,t,n,o,s){if(void 0===s&&(s=!1),!e||!t)return!1;if(e.nodeName!==t.nodeName)return!1;if(["#text","#comment"].includes(e.nodeName))return!!s||e.data===t.data;if(e.nodeName in n)return!0;if(e.attributes&&t.attributes){if(e.attributes.id){if(e.attributes.id!==t.attributes.id)return!1;if("".concat(e.nodeName,"#").concat(e.attributes.id)in n)return!0}if(e.attributes.class&&e.attributes.class===t.attributes.class)if("".concat(e.nodeName,".").concat(e.attributes.class.replace(/ /g,"."))in n)return!0}if(o)return!0;var i=e.childNodes?e.childNodes.slice().reverse():[],a=t.childNodes?t.childNodes.slice().reverse():[];if(i.length!==a.length)return!1;if(s)return i.every((function(e,t){return e.nodeName===a[t].nodeName}));var c=l(i,a);return i.every((function(e,t){return h(e,a[t],c,!0,!0)}))},f=function(e,t){return Array.apply(void 0,new Array(e)).map((function(){return t}))},p=function(e,t){for(var n=e.childNodes?e.childNodes:[],o=t.childNodes?t.childNodes:[],s=f(n.length,!1),i=f(o.length,!1),c=[],r=function(){return arguments[1]},u=!1,d=function(){var e=function(e,t,n,o){var s=0,i=[],c=e.length,r=t.length,u=Array.apply(void 0,new Array(c+1)).map((function(){return[]})),d=l(e,t),f=c===r;f&&e.some((function(e,n){var o=a(e),s=a(t[n]);return o.length!==s.length?(f=!1,!0):(o.some((function(e,t){if(e!==s[t])return f=!1,!0})),!f||void 0)}));for(var p=0;p<c;p++)for(var m=e[p],_=0;_<r;_++){var V=t[_];n[p]||o[_]||!h(m,V,d,f)?u[p+1][_+1]=0:(u[p+1][_+1]=u[p][_]?u[p][_]+1:1,u[p+1][_+1]>=s&&(s=u[p+1][_+1],i=[p+1,_+1]))}return 0!==s&&{oldValue:i[0]-s,newValue:i[1]-s,length:s}}(n,o,s,i);e?(c.push(e),Array.apply(void 0,new Array(e.length)).map(r).forEach((function(t){return function(e,t,n,o){e[n.oldValue+o]=!0,t[n.newValue+o]=!0}(s,i,e,t)}))):u=!0};!u;)d();return e.subsets=c,e.subsetsAge=100,c},m=function(){function e(){this.list=[]}return e.prototype.add=function(e){var t;(t=this.list).push.apply(t,e)},e.prototype.forEach=function(e){this.list.forEach((function(t){return e(t)}))},e}(),_=function(){function e(e){void 0===e&&(e={});var t=this;Object.entries(e).forEach((function(e){var n=e[0],o=e[1];return t[n]=o}))}return e.prototype.toString=function(){return JSON.stringify(this)},e.prototype.setValue=function(e,t){return this[e]=t,this},e}();function V(e,t){var n,o,s=e;for(t=t.slice();t.length>0;)o=t.splice(0,1)[0],n=s,s=s.childNodes?s.childNodes[o]:void 0;return{node:s,parentNode:n,nodeIndex:o}}function g(e,t,n){return t.forEach((function(t){!function(e,t,n){var o,s,i,a;if(![n._const.addElement,n._const.addTextElement].includes(t[n._const.action])){var c=V(e,t[n._const.route]);s=c.node,i=c.parentNode,a=c.nodeIndex}var l,r,d=[],h={diff:t,node:s};if(n.preVirtualDiffApply(h))return!0;switch(t[n._const.action]){case n._const.addAttribute:s.attributes||(s.attributes={}),s.attributes[t[n._const.name]]=t[n._const.value],"checked"===t[n._const.name]?s.checked=!0:"selected"===t[n._const.name]?s.selected=!0:"INPUT"===s.nodeName&&"value"===t[n._const.name]&&(s.value=t[n._const.value]);break;case n._const.modifyAttribute:s.attributes[t[n._const.name]]=t[n._const.newValue];break;case n._const.removeAttribute:delete s.attributes[t[n._const.name]],0===Object.keys(s.attributes).length&&delete s.attributes,"checked"===t[n._const.name]?s.checked=!1:"selected"===t[n._const.name]?delete s.selected:"INPUT"===s.nodeName&&"value"===t[n._const.name]&&delete s.value;break;case n._const.modifyTextElement:s.data=t[n._const.newValue],"TEXTAREA"===i.nodeName&&(i.value=t[n._const.newValue]);break;case n._const.modifyValue:s.value=t[n._const.newValue];break;case n._const.modifyComment:s.data=t[n._const.newValue];break;case n._const.modifyChecked:s.checked=t[n._const.newValue];break;case n._const.modifySelected:s.selected=t[n._const.newValue];break;case n._const.replaceElement:l=u(t[n._const.newValue]),i.childNodes[a]=l;break;case n._const.relocateGroup:s.childNodes.splice(t[n._const.from],t[n._const.groupLength]).reverse().forEach((function(e){return s.childNodes.splice(t[n._const.to],0,e)})),s.subsets&&s.subsets.forEach((function(e){if(t[n._const.from]<t[n._const.to]&&e.oldValue<=t[n._const.to]&&e.oldValue>t[n._const.from])e.oldValue-=t[n._const.groupLength],(o=e.oldValue+e.length-t[n._const.to])>0&&(d.push({oldValue:t[n._const.to]+t[n._const.groupLength],newValue:e.newValue+e.length-o,length:o}),e.length-=o);else if(t[n._const.from]>t[n._const.to]&&e.oldValue>t[n._const.to]&&e.oldValue<t[n._const.from]){var o;e.oldValue+=t[n._const.groupLength],(o=e.oldValue+e.length-t[n._const.to])>0&&(d.push({oldValue:t[n._const.to]+t[n._const.groupLength],newValue:e.newValue+e.length-o,length:o}),e.length-=o)}else e.oldValue===t[n._const.from]&&(e.oldValue=t[n._const.to])}));break;case n._const.removeElement:i.childNodes.splice(a,1),i.subsets&&i.subsets.forEach((function(e){e.oldValue>a?e.oldValue-=1:e.oldValue===a?e.delete=!0:e.oldValue<a&&e.oldValue+e.length>a&&(e.oldValue+e.length-1===a?e.length--:(d.push({newValue:e.newValue+a-e.oldValue,oldValue:a,length:e.length-a+e.oldValue-1}),e.length=a-e.oldValue))})),s=i;break;case n._const.addElement:var f=(r=t[n._const.route].slice()).splice(r.length-1,1)[0];s=null===(o=V(e,r))||void 0===o?void 0:o.node,l=u(t[n._const.element]),s.childNodes||(s.childNodes=[]),f>=s.childNodes.length?s.childNodes.push(l):s.childNodes.splice(f,0,l),s.subsets&&s.subsets.forEach((function(e){if(e.oldValue>=f)e.oldValue+=1;else if(e.oldValue<f&&e.oldValue+e.length>f){var t=e.oldValue+e.length-f;d.push({newValue:e.newValue+e.length-t,oldValue:f+1,length:t}),e.length-=t}}));break;case n._const.removeTextElement:i.childNodes.splice(a,1),"TEXTAREA"===i.nodeName&&delete i.value,i.subsets&&i.subsets.forEach((function(e){e.oldValue>a?e.oldValue-=1:e.oldValue===a?e.delete=!0:e.oldValue<a&&e.oldValue+e.length>a&&(e.oldValue+e.length-1===a?e.length--:(d.push({newValue:e.newValue+a-e.oldValue,oldValue:a,length:e.length-a+e.oldValue-1}),e.length=a-e.oldValue))})),s=i;break;case n._const.addTextElement:var p=(r=t[n._const.route].slice()).splice(r.length-1,1)[0];l={nodeName:"#text",data:t[n._const.value]},(s=V(e,r).node).childNodes||(s.childNodes=[]),p>=s.childNodes.length?s.childNodes.push(l):s.childNodes.splice(p,0,l),"TEXTAREA"===s.nodeName&&(s.value=t[n._const.newValue]),s.subsets&&s.subsets.forEach((function(e){if(e.oldValue>=p&&(e.oldValue+=1),e.oldValue<p&&e.oldValue+e.length>p){var t=e.oldValue+e.length-p;d.push({newValue:e.newValue+e.length-t,oldValue:p+1,length:t}),e.length-=t}}));break;default:console.log("unknown action")}s.subsets&&(s.subsets=s.subsets.filter((function(e){return!e.delete&&e.oldValue!==e.newValue})),d.length&&(s.subsets=s.subsets.concat(d))),n.postVirtualDiffApply({node:h.node,diff:h.diff,newNode:l})}(e,t,n)})),!0}function v(e,t){void 0===t&&(t={valueDiffing:!0});var n={nodeName:e.nodeName};if(e instanceof Text||e instanceof Comment)n.data=e.data;else{if(e.attributes&&e.attributes.length>0)n.attributes={},Array.prototype.slice.call(e.attributes).forEach((function(e){return n.attributes[e.name]=e.value}));if(e.childNodes&&e.childNodes.length>0)n.childNodes=[],Array.prototype.slice.call(e.childNodes).forEach((function(e){return n.childNodes.push(v(e,t))}));t.valueDiffing&&(e instanceof HTMLTextAreaElement&&(n.value=e.value),e instanceof HTMLInputElement&&["radio","checkbox"].includes(e.type.toLowerCase())&&void 0!==e.checked?n.checked=e.checked:(e instanceof HTMLButtonElement||e instanceof HTMLDataElement||e instanceof HTMLInputElement||e instanceof HTMLLIElement||e instanceof HTMLMeterElement||e instanceof HTMLOptionElement||e instanceof HTMLProgressElement||e instanceof HTMLParamElement)&&(n.value=e.value),e instanceof HTMLOptionElement&&(n.selected=e.selected))}return n}var b=/<\s*\/*[a-zA-Z:_][a-zA-Z0-9:_\-.]*\s*(?:"[^"]*"['"]*|'[^']*'['"]*|[^'"/>])*\/*\s*>|<!--(?:.|\n|\r)*?-->/g,N=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function y(e){return e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&")}var w={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,menuItem:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},E=function(e,t){var n={nodeName:"",attributes:{}},o=!1,s=e.match(/<\/?([^\s]+?)[/\s>]/);if(s&&(n.nodeName=t||"svg"===s[1]?s[1]:s[1].toUpperCase(),(w[s[1]]||"/"===e.charAt(e.length-2))&&(o=!0),n.nodeName.startsWith("!--"))){var i=e.indexOf("--\x3e");return{type:"comment",node:{nodeName:"#comment",data:-1!==i?e.slice(4,i):""},voidElement:o}}for(var a=new RegExp(N),c=null,l=!1;!l;)if(null===(c=a.exec(e)))l=!0;else if(c[0].trim())if(c[1]){var r=c[1].trim(),u=[r,""];r.indexOf("=")>-1&&(u=r.split("=")),n.attributes[u[0]]=u[1],a.lastIndex--}else c[2]&&(n.attributes[c[2]]=c[3].trim().substring(1,c[3].length-1));return{type:"tag",node:n,voidElement:o}},k=function(e,t){void 0===t&&(t={valueDiffing:!0,caseSensitive:!1});var n,o=[],s=-1,i=[],a=!1;if(0!==e.indexOf("<")){var c=e.indexOf("<");o.push({nodeName:"#text",data:-1===c?e:e.substring(0,c)})}return e.replace(b,(function(c,l){var r="/"!==c.charAt(1),u=c.startsWith("\x3c!--"),d=l+c.length,h=e.charAt(d);if(u){var f=E(c,t.caseSensitive).node;if(s<0)return o.push(f),"";var p=i[s];return p&&f.nodeName&&(p.node.childNodes||(p.node.childNodes=[]),p.node.childNodes.push(f)),""}if(r){if("svg"===(n=E(c,t.caseSensitive||a)).node.nodeName&&(a=!0),s++,!n.voidElement&&h&&"<"!==h){n.node.childNodes||(n.node.childNodes=[]);var m=y(e.slice(d,e.indexOf("<",d)));n.node.childNodes.push({nodeName:"#text",data:m}),t.valueDiffing&&"TEXTAREA"===n.node.nodeName&&(n.node.value=m)}0===s&&n.node.nodeName&&o.push(n.node);var _=i[s-1];_&&n.node.nodeName&&(_.node.childNodes||(_.node.childNodes=[]),_.node.childNodes.push(n.node)),i[s]=n}if((!r||n.voidElement)&&(s>-1&&(n.voidElement||t.caseSensitive&&n.node.nodeName===c.slice(2,-1)||!t.caseSensitive&&n.node.nodeName.toUpperCase()===c.slice(2,-1).toUpperCase())&&--s>-1&&("svg"===n.node.nodeName&&(a=!1),n=i[s]),"<"!==h&&h)){var V=-1===s?o:i[s].node.childNodes||[],g=e.indexOf("<",d);m=y(e.slice(d,-1===g?void 0:g));V.push({nodeName:"#text",data:m})}return""})),o[0]},x=function(){function e(e,t,n){this.options=n,this.t1="undefined"!=typeof Element&&e instanceof Element?v(e,this.options):"string"==typeof e?k(e,this.options):JSON.parse(JSON.stringify(e)),this.t2="undefined"!=typeof Element&&t instanceof Element?v(t,this.options):"string"==typeof t?k(t,this.options):JSON.parse(JSON.stringify(t)),this.diffcount=0,this.foundAll=!1,this.debug&&(this.t1Orig="undefined"!=typeof Element&&e instanceof Element?v(e,this.options):"string"==typeof e?k(e,this.options):JSON.parse(JSON.stringify(e)),this.t2Orig="undefined"!=typeof Element&&t instanceof Element?v(t,this.options):"string"==typeof t?k(t,this.options):JSON.parse(JSON.stringify(t))),this.tracker=new m}return e.prototype.init=function(){return this.findDiffs(this.t1,this.t2)},e.prototype.findDiffs=function(e,t){var n;do{if(this.options.debug&&(this.diffcount+=1,this.diffcount>this.options.diffcap))throw new Error("surpassed diffcap:".concat(JSON.stringify(this.t1Orig)," -> ").concat(JSON.stringify(this.t2Orig)));0===(n=this.findNextDiff(e,t,[])).length&&(d(e,t)||(this.foundAll?console.error("Could not find remaining diffs!"):(this.foundAll=!0,r(e),n=this.findNextDiff(e,t,[])))),n.length>0&&(this.foundAll=!1,this.tracker.add(n),g(e,n,this.options))}while(n.length>0);return this.tracker.list},e.prototype.findNextDiff=function(e,t,n){var o,s;if(this.options.maxDepth&&n.length>this.options.maxDepth)return[];if(!e.outerDone){if(o=this.findOuterDiff(e,t,n),this.options.filterOuterDiff&&(s=this.options.filterOuterDiff(e,t,o))&&(o=s),o.length>0)return e.outerDone=!0,o;e.outerDone=!0}if(Object.prototype.hasOwnProperty.call(e,"data"))return[];if(!e.innerDone){if((o=this.findInnerDiff(e,t,n)).length>0)return o;e.innerDone=!0}if(this.options.valueDiffing&&!e.valueDone){if((o=this.findValueDiff(e,t,n)).length>0)return e.valueDone=!0,o;e.valueDone=!0}return[]},e.prototype.findOuterDiff=function(e,t,n){var o,s,i,a,c,l,r=[];if(e.nodeName!==t.nodeName){if(!n.length)throw new Error("Top level nodes have to be of the same kind.");return[(new _).setValue(this.options._const.action,this.options._const.replaceElement).setValue(this.options._const.oldValue,u(e)).setValue(this.options._const.newValue,u(t)).setValue(this.options._const.route,n)]}if(n.length&&this.options.diffcap<Math.abs((e.childNodes||[]).length-(t.childNodes||[]).length))return[(new _).setValue(this.options._const.action,this.options._const.replaceElement).setValue(this.options._const.oldValue,u(e)).setValue(this.options._const.newValue,u(t)).setValue(this.options._const.route,n)];if(Object.prototype.hasOwnProperty.call(e,"data")&&e.data!==t.data)return"#text"===e.nodeName?[(new _).setValue(this.options._const.action,this.options._const.modifyTextElement).setValue(this.options._const.route,n).setValue(this.options._const.oldValue,e.data).setValue(this.options._const.newValue,t.data)]:[(new _).setValue(this.options._const.action,this.options._const.modifyComment).setValue(this.options._const.route,n).setValue(this.options._const.oldValue,e.data).setValue(this.options._const.newValue,t.data)];for(s=e.attributes?Object.keys(e.attributes).sort():[],i=t.attributes?Object.keys(t.attributes).sort():[],a=s.length,l=0;l<a;l++)o=s[l],-1===(c=i.indexOf(o))?r.push((new _).setValue(this.options._const.action,this.options._const.removeAttribute).setValue(this.options._const.route,n).setValue(this.options._const.name,o).setValue(this.options._const.value,e.attributes[o])):(i.splice(c,1),e.attributes[o]!==t.attributes[o]&&r.push((new _).setValue(this.options._const.action,this.options._const.modifyAttribute).setValue(this.options._const.route,n).setValue(this.options._const.name,o).setValue(this.options._const.oldValue,e.attributes[o]).setValue(this.options._const.newValue,t.attributes[o])));for(a=i.length,l=0;l<a;l++)o=i[l],r.push((new _).setValue(this.options._const.action,this.options._const.addAttribute).setValue(this.options._const.route,n).setValue(this.options._const.name,o).setValue(this.options._const.value,t.attributes[o]));return r},e.prototype.findInnerDiff=function(e,t,n){var o=e.childNodes?e.childNodes.slice():[],s=t.childNodes?t.childNodes.slice():[],i=Math.max(o.length,s.length),a=Math.abs(o.length-s.length),c=[],l=0;if(!this.options.maxChildCount||i<this.options.maxChildCount){var r=Boolean(e.subsets&&e.subsetsAge--),h=r?e.subsets:e.childNodes&&t.childNodes?p(e,t):[];if(h.length>0&&(c=this.attemptGroupRelocation(e,t,h,n,r)).length>0)return c}for(var f=0;f<i;f+=1){var m=o[f],V=s[f];a&&(m&&!V?"#text"===m.nodeName?(c.push((new _).setValue(this.options._const.action,this.options._const.removeTextElement).setValue(this.options._const.route,n.concat(l)).setValue(this.options._const.value,m.data)),l-=1):(c.push((new _).setValue(this.options._const.action,this.options._const.removeElement).setValue(this.options._const.route,n.concat(l)).setValue(this.options._const.element,u(m))),l-=1):V&&!m&&("#text"===V.nodeName?c.push((new _).setValue(this.options._const.action,this.options._const.addTextElement).setValue(this.options._const.route,n.concat(l)).setValue(this.options._const.value,V.data)):c.push((new _).setValue(this.options._const.action,this.options._const.addElement).setValue(this.options._const.route,n.concat(l)).setValue(this.options._const.element,u(V))))),m&&V&&(!this.options.maxChildCount||i<this.options.maxChildCount?c=c.concat(this.findNextDiff(m,V,n.concat(l))):d(m,V)||(o.length>s.length?("#text"===m.nodeName?c.push((new _).setValue(this.options._const.action,this.options._const.removeTextElement).setValue(this.options._const.route,n.concat(l)).setValue(this.options._const.value,m.data)):c.push((new _).setValue(this.options._const.action,this.options._const.removeElement).setValue(this.options._const.element,u(m)).setValue(this.options._const.route,n.concat(l))),o.splice(f,1),f-=1,l-=1,a-=1):o.length<s.length?(c=c.concat([(new _).setValue(this.options._const.action,this.options._const.addElement).setValue(this.options._const.element,u(V)).setValue(this.options._const.route,n.concat(l))]),o.splice(f,0,u(V)),a-=1):c=c.concat([(new _).setValue(this.options._const.action,this.options._const.replaceElement).setValue(this.options._const.oldValue,u(m)).setValue(this.options._const.newValue,u(V)).setValue(this.options._const.route,n.concat(l))]))),l+=1}return e.innerDone=!0,c},e.prototype.attemptGroupRelocation=function(e,t,n,o,s){for(var i,a,c,l,r,d=function(e,t,n){var o=e.childNodes?f(e.childNodes.length,!0):[],s=t.childNodes?f(t.childNodes.length,!0):[],i=0;return n.forEach((function(e){for(var t=e.oldValue+e.length,n=e.newValue+e.length,a=e.oldValue;a<t;a+=1)o[a]=i;for(a=e.newValue;a<n;a+=1)s[a]=i;i+=1})),{gaps1:o,gaps2:s}}(e,t,n),p=d.gaps1,m=d.gaps2,V=e.childNodes.slice(),g=t.childNodes.slice(),v=Math.min(p.length,m.length),b=[],N=0,y=0;N<v;y+=1,N+=1)if(!s||!0!==p[N]&&!0!==m[N]){if(!0===p[y])if("#text"===(l=V[y]).nodeName)if("#text"===g[N].nodeName){if(l.data!==g[N].data){for(var w=y;V.length>w+1&&"#text"===V[w+1].nodeName;)if(w+=1,g[N].data===V[w].data){r=!0;break}r||b.push((new _).setValue(this.options._const.action,this.options._const.modifyTextElement).setValue(this.options._const.route,o.concat(y)).setValue(this.options._const.oldValue,l.data).setValue(this.options._const.newValue,g[N].data))}}else b.push((new _).setValue(this.options._const.action,this.options._const.removeTextElement).setValue(this.options._const.route,o.concat(y)).setValue(this.options._const.value,l.data)),p.splice(y,1),V.splice(y,1),v=Math.min(p.length,m.length),y-=1,N-=1;else!0===m[N]?b.push((new _).setValue(this.options._const.action,this.options._const.replaceElement).setValue(this.options._const.oldValue,u(l)).setValue(this.options._const.newValue,u(g[N])).setValue(this.options._const.route,o.concat(y))):(b.push((new _).setValue(this.options._const.action,this.options._const.removeElement).setValue(this.options._const.route,o.concat(y)).setValue(this.options._const.element,u(l))),p.splice(y,1),V.splice(y,1),v=Math.min(p.length,m.length),y-=1,N-=1);else if(!0===m[N])"#text"===(l=g[N]).nodeName?(b.push((new _).setValue(this.options._const.action,this.options._const.addTextElement).setValue(this.options._const.route,o.concat(y)).setValue(this.options._const.value,l.data)),p.splice(y,0,!0),V.splice(y,0,{nodeName:"#text",data:l.data}),v=Math.min(p.length,m.length)):(b.push((new _).setValue(this.options._const.action,this.options._const.addElement).setValue(this.options._const.route,o.concat(y)).setValue(this.options._const.element,u(l))),p.splice(y,0,!0),V.splice(y,0,u(l)),v=Math.min(p.length,m.length));else if(p[y]!==m[N]){if(b.length>0)return b;if(c=n[p[y]],(a=Math.min(c.newValue,V.length-c.length))!==c.oldValue){i=!1;for(var E=0;E<c.length;E+=1)h(V[a+E],V[c.oldValue+E],{},!1,!0)||(i=!0);if(i)return[(new _).setValue(this.options._const.action,this.options._const.relocateGroup).setValue(this.options._const.groupLength,c.length).setValue(this.options._const.from,c.oldValue).setValue(this.options._const.to,a).setValue(this.options._const.route,o)]}}}else;return b},e.prototype.findValueDiff=function(e,t,n){var o=[];return e.selected!==t.selected&&o.push((new _).setValue(this.options._const.action,this.options._const.modifySelected).setValue(this.options._const.oldValue,e.selected).setValue(this.options._const.newValue,t.selected).setValue(this.options._const.route,n)),(e.value||t.value)&&e.value!==t.value&&"OPTION"!==e.nodeName&&o.push((new _).setValue(this.options._const.action,this.options._const.modifyValue).setValue(this.options._const.oldValue,e.value||"").setValue(this.options._const.newValue,t.value||"").setValue(this.options._const.route,n)),e.checked!==t.checked&&o.push((new _).setValue(this.options._const.action,this.options._const.modifyChecked).setValue(this.options._const.oldValue,e.checked).setValue(this.options._const.newValue,t.checked).setValue(this.options._const.route,n)),o},e}(),T={debug:!1,diffcap:10,maxDepth:!1,maxChildCount:50,valueDiffing:!0,textDiff:function(e,t,n,o){e.data=o},preVirtualDiffApply:function(){},postVirtualDiffApply:function(){},preDiffApply:function(){},postDiffApply:function(){},filterOuterDiff:null,compress:!1,_const:!1,document:!("undefined"==typeof window||!window.document)&&window.document,components:[]},O=function(){function e(e){if(void 0===e&&(e={}),Object.entries(T).forEach((function(t){var n=t[0],o=t[1];Object.prototype.hasOwnProperty.call(e,n)||(e[n]=o)})),!e._const){var t=["addAttribute","modifyAttribute","removeAttribute","modifyTextElement","relocateGroup","removeElement","addElement","removeTextElement","addTextElement","replaceElement","modifyValue","modifyChecked","modifySelected","modifyComment","action","route","oldValue","newValue","element","group","groupLength","from","to","name","value","data","attributes","nodeName","childNodes","checked","selected"],n={};e.compress?t.forEach((function(e,t){return n[e]=t})):t.forEach((function(e){return n[e]=e})),e._const=n}this.options=e}return e.prototype.apply=function(e,t){return function(e,t,o){return t.every((function(t){return n(e,t,o)}))}(e,t,this.options)},e.prototype.undo=function(e,t){return s(e,t,this.options)},e.prototype.diff=function(e,t){return new x(e,t,this.options).init()},e}(),A=function(){function e(e){void 0===e&&(e={});var t=this;this.pad="│ ",this.padding="",this.tick=1,this.messages=[];var n=function(e,n){var o=e[n];e[n]=function(){for(var s=arguments,i=[],a=0;a<arguments.length;a++)i[a]=s[a];t.fin(n,Array.prototype.slice.call(i));var c=o.apply(e,i);return t.fout(n,c),c}};for(var o in e)"function"==typeof e[o]&&n(e,o);this.log("┌ TRACELOG START")}return e.prototype.fin=function(e,t){this.padding+=this.pad,this.log("├─> entering ".concat(e),t)},e.prototype.fout=function(e,t){this.log("│<──┘ generated return value",t),this.padding=this.padding.substring(0,this.padding.length-this.pad.length)},e.prototype.format=function(e,t){return"".concat(function(e){for(var t="".concat(e);t.length<4;)t="0".concat(e);return t}(t),"> ").concat(this.padding).concat(e)},e.prototype.log=function(){for(var e=arguments,t=[],n=0;n<arguments.length;n++)t[n]=e[n];var o=function(e){return e?"string"==typeof e?e:e instanceof HTMLElement?e.outerHTML||"<empty>":e instanceof Array?"[".concat(e.map(o).join(","),"]"):e.toString()||e.valueOf()||"<unknown>":"<falsey>"},s=t.map(o).join(", ");this.messages.push(this.format(s,this.tick++))},e.prototype.toString=function(){for(var e="└───";e.length<=this.padding.length+this.pad.length;)e+="× ";var t=this.padding;return this.padding="",e=this.format(e,this.tick),this.padding=t,"".concat(this.messages.join("\n"),"\n").concat(e)},e}();exports.DiffDOM=O,exports.TraceLogger=A,exports.nodeToObj=v,exports.stringToObj=k;
"use strict";var e=function(){function e(e){var t=this;void 0===e&&(e={}),Object.entries(e).forEach((function(e){var n=e[0],o=e[1];return t[n]=o}))}return e.prototype.toString=function(){return JSON.stringify(this)},e.prototype.setValue=function(e,t){return this[e]=t,this},e}(),t=function(e){for(var t,n=arguments,o=[],s=1;s<arguments.length;s++)o[s-1]=n[s];if(null==e)return!1;var i=global||(null===(t=null==e?void 0:e.ownerDocument)||void 0===t?void 0:t.defaultView)||window;return o.some((function(t){return"function"==typeof(null==i?void 0:i[t])&&e instanceof i[t]}))};function n(e,o,s){var i;return"#text"===e.nodeName?i=s.document.createTextNode(e.data):"#comment"===e.nodeName?i=s.document.createComment(e.data):(o?i=s.document.createElementNS("http://www.w3.org/2000/svg",e.nodeName):"svg"===e.nodeName.toLowerCase()?(i=s.document.createElementNS("http://www.w3.org/2000/svg","svg"),o=!0):i=s.document.createElement(e.nodeName),e.attributes&&Object.entries(e.attributes).forEach((function(e){var t=e[0],n=e[1];return i.setAttribute(t,n)})),e.childNodes&&e.childNodes.forEach((function(e){return i.appendChild(n(e,o,s))})),s.valueDiffing&&(e.value&&t(i,"HTMLButtonElement","HTMLDataElement","HTMLInputElement","HTMLLIElement","HTMLMeterElement","HTMLOptionElement","HTMLProgressElement","HTMLParamElement")&&(i.value=e.value),e.checked&&t(i,"HTMLInputElement")&&(i.checked=e.checked),e.selected&&t(i,"HTMLOptionElement")&&(i.selected=e.selected))),i}var o=function(e,t){for(t=t.slice();t.length>0;){var n=t.splice(0,1)[0];e=e.childNodes[n]}return e};function s(e,s,i){var a,l,c,r=s[i._const.action],u=s[i._const.route];[i._const.addElement,i._const.addTextElement].includes(r)||(a=o(e,u));var d={diff:s,node:a};if(i.preDiffApply(d))return!0;switch(r){case i._const.addAttribute:if(!a||!t(a,"Element"))return!1;a.setAttribute(s[i._const.name],s[i._const.value]);break;case i._const.modifyAttribute:if(!a||!t(a,"Element"))return!1;a.setAttribute(s[i._const.name],s[i._const.newValue]),t(a,"HTMLInputElement")&&"value"===s[i._const.name]&&(a.value=s[i._const.newValue]);break;case i._const.removeAttribute:if(!a||!t(a,"Element"))return!1;a.removeAttribute(s[i._const.name]);break;case i._const.modifyTextElement:if(!a||!t(a,"Text"))return!1;i.textDiff(a,a.data,s[i._const.oldValue],s[i._const.newValue]),t(a.parentNode,"HTMLTextAreaElement")&&(a.parentNode.value=s[i._const.newValue]);break;case i._const.modifyValue:if(!a||void 0===a.value)return!1;a.value=s[i._const.newValue];break;case i._const.modifyComment:if(!a||!t(a,"Comment"))return!1;i.textDiff(a,a.data,s[i._const.oldValue],s[i._const.newValue]);break;case i._const.modifyChecked:if(!a||void 0===a.checked)return!1;a.checked=s[i._const.newValue];break;case i._const.modifySelected:if(!a||void 0===a.selected)return!1;a.selected=s[i._const.newValue];break;case i._const.replaceElement:var h="svg"===s[i._const.newValue].nodeName.toLowerCase()||"http://www.w3.org/2000/svg"===a.parentNode.namespaceURI;a.parentNode.replaceChild(n(s[i._const.newValue],h,i),a);break;case i._const.relocateGroup:Array.apply(void 0,new Array(s[i._const.groupLength])).map((function(){return a.removeChild(a.childNodes[s[i._const.from]])})).forEach((function(e,t){0===t&&(c=a.childNodes[s[i._const.to]]),a.insertBefore(e,c||null)}));break;case i._const.removeElement:a.parentNode.removeChild(a);break;case i._const.addElement:var p=(m=u.slice()).splice(m.length-1,1)[0];if(a=o(e,m),!t(a,"Element"))return!1;a.insertBefore(n(s[i._const.element],"http://www.w3.org/2000/svg"===a.namespaceURI,i),a.childNodes[p]||null);break;case i._const.removeTextElement:if(!a||3!==a.nodeType)return!1;var f=a.parentNode;f.removeChild(a),t(f,"HTMLTextAreaElement")&&(f.value="");break;case i._const.addTextElement:var m;p=(m=u.slice()).splice(m.length-1,1)[0];if(l=i.document.createTextNode(s[i._const.value]),!(a=o(e,m)).childNodes)return!1;a.insertBefore(l,a.childNodes[p]||null),t(a.parentNode,"HTMLTextAreaElement")&&(a.parentNode.value=s[i._const.value]);break;default:console.log("unknown action")}return i.postDiffApply({diff:d.diff,node:d.node,newNode:l}),!0}function i(e,t,n){var o=e[t];e[t]=e[n],e[n]=o}function a(e,t,n){(t=t.slice()).reverse(),t.forEach((function(t){!function(e,t,n){switch(t[n._const.action]){case n._const.addAttribute:t[n._const.action]=n._const.removeAttribute,s(e,t,n);break;case n._const.modifyAttribute:i(t,n._const.oldValue,n._const.newValue),s(e,t,n);break;case n._const.removeAttribute:t[n._const.action]=n._const.addAttribute,s(e,t,n);break;case n._const.modifyTextElement:case n._const.modifyValue:case n._const.modifyComment:case n._const.modifyChecked:case n._const.modifySelected:case n._const.replaceElement:i(t,n._const.oldValue,n._const.newValue),s(e,t,n);break;case n._const.relocateGroup:i(t,n._const.from,n._const.to),s(e,t,n);break;case n._const.removeElement:t[n._const.action]=n._const.addElement,s(e,t,n);break;case n._const.addElement:t[n._const.action]=n._const.removeElement,s(e,t,n);break;case n._const.removeTextElement:t[n._const.action]=n._const.addTextElement,s(e,t,n);break;case n._const.addTextElement:t[n._const.action]=n._const.removeTextElement,s(e,t,n);break;default:console.log("unknown action")}}(e,t,n)}))}var l=function(){return l=Object.assign||function(e){for(var t,n=arguments,o=1,s=arguments.length;o<s;o++)for(var i in t=n[o])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},l.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var c=function(e){var t=[];return t.push(e.nodeName),"#text"!==e.nodeName&&"#comment"!==e.nodeName&&e.attributes&&(e.attributes.class&&t.push("".concat(e.nodeName,".").concat(e.attributes.class.replace(/ /g,"."))),e.attributes.id&&t.push("".concat(e.nodeName,"#").concat(e.attributes.id))),t},r=function(e){var t={},n={};return e.forEach((function(e){c(e).forEach((function(e){var o=e in t;o||e in n?o&&(delete t[e],n[e]=!0):t[e]=!0}))})),t},u=function(e,t){var n=r(e),o=r(t),s={};return Object.keys(n).forEach((function(e){o[e]&&(s[e]=!0)})),s},d=function(e){return delete e.outerDone,delete e.innerDone,delete e.valueDone,!e.childNodes||e.childNodes.every(d)},h=function(e){if(Object.prototype.hasOwnProperty.call(e,"data"))return{nodeName:"#text"===e.nodeName?"#text":"#comment",data:e.data};var t={nodeName:e.nodeName};return Object.prototype.hasOwnProperty.call(e,"attributes")&&(t.attributes=l({},e.attributes)),Object.prototype.hasOwnProperty.call(e,"checked")&&(t.checked=e.checked),Object.prototype.hasOwnProperty.call(e,"value")&&(t.value=e.value),Object.prototype.hasOwnProperty.call(e,"selected")&&(t.selected=e.selected),Object.prototype.hasOwnProperty.call(e,"childNodes")&&(t.childNodes=e.childNodes.map((function(e){return h(e)}))),t},p=function(e,t){if(!["nodeName","value","checked","selected","data"].every((function(n){return e[n]===t[n]})))return!1;if(Object.prototype.hasOwnProperty.call(e,"data"))return!0;if(Boolean(e.attributes)!==Boolean(t.attributes))return!1;if(Boolean(e.childNodes)!==Boolean(t.childNodes))return!1;if(e.attributes){var n=Object.keys(e.attributes),o=Object.keys(t.attributes);if(n.length!==o.length)return!1;if(!n.every((function(n){return e.attributes[n]===t.attributes[n]})))return!1}if(e.childNodes){if(e.childNodes.length!==t.childNodes.length)return!1;if(!e.childNodes.every((function(e,n){return p(e,t.childNodes[n])})))return!1}return!0},f=function(e,t,n,o,s){if(void 0===s&&(s=!1),!e||!t)return!1;if(e.nodeName!==t.nodeName)return!1;if(["#text","#comment"].includes(e.nodeName))return!!s||e.data===t.data;if(e.nodeName in n)return!0;if(e.attributes&&t.attributes){if(e.attributes.id){if(e.attributes.id!==t.attributes.id)return!1;if("".concat(e.nodeName,"#").concat(e.attributes.id)in n)return!0}if(e.attributes.class&&e.attributes.class===t.attributes.class)if("".concat(e.nodeName,".").concat(e.attributes.class.replace(/ /g,"."))in n)return!0}if(o)return!0;var i=e.childNodes?e.childNodes.slice().reverse():[],a=t.childNodes?t.childNodes.slice().reverse():[];if(i.length!==a.length)return!1;if(s)return i.every((function(e,t){return e.nodeName===a[t].nodeName}));var l=u(i,a);return i.every((function(e,t){return f(e,a[t],l,!0,!0)}))},m=function(e,t){return Array.apply(void 0,new Array(e)).map((function(){return t}))},_=function(e,t){for(var n=e.childNodes?e.childNodes:[],o=t.childNodes?t.childNodes:[],s=m(n.length,!1),i=m(o.length,!1),a=[],l=function(){return arguments[1]},r=!1,d=function(){var e=function(e,t,n,o){var s=0,i=[],a=e.length,l=t.length,r=Array.apply(void 0,new Array(a+1)).map((function(){return[]})),d=u(e,t),h=a===l;h&&e.some((function(e,n){var o=c(e),s=c(t[n]);return o.length!==s.length?(h=!1,!0):(o.some((function(e,t){if(e!==s[t])return h=!1,!0})),!h||void 0)}));for(var p=0;p<a;p++)for(var m=e[p],_=0;_<l;_++){var v=t[_];n[p]||o[_]||!f(m,v,d,h)?r[p+1][_+1]=0:(r[p+1][_+1]=r[p][_]?r[p][_]+1:1,r[p+1][_+1]>=s&&(s=r[p+1][_+1],i=[p+1,_+1]))}return 0!==s&&{oldValue:i[0]-s,newValue:i[1]-s,length:s}}(n,o,s,i);e?(a.push(e),Array.apply(void 0,new Array(e.length)).map(l).forEach((function(t){return function(e,t,n,o){e[n.oldValue+o]=!0,t[n.newValue+o]=!0}(s,i,e,t)}))):r=!0};!r;)d();return e.subsets=a,e.subsetsAge=100,a},v=function(){function e(){this.list=[]}return e.prototype.add=function(e){var t;(t=this.list).push.apply(t,e)},e.prototype.forEach=function(e){this.list.forEach((function(t){return e(t)}))},e}();function g(e,t){var n,o,s=e;for(t=t.slice();t.length>0;)o=t.splice(0,1)[0],n=s,s=s.childNodes?s.childNodes[o]:void 0;return{node:s,parentNode:n,nodeIndex:o}}function V(e,t,n){return t.forEach((function(t){!function(e,t,n){var o,s,i,a;if(![n._const.addElement,n._const.addTextElement].includes(t[n._const.action])){var l=g(e,t[n._const.route]);s=l.node,i=l.parentNode,a=l.nodeIndex}var c,r,u=[],d={diff:t,node:s};if(n.preVirtualDiffApply(d))return!0;switch(t[n._const.action]){case n._const.addAttribute:s.attributes||(s.attributes={}),s.attributes[t[n._const.name]]=t[n._const.value],"checked"===t[n._const.name]?s.checked=!0:"selected"===t[n._const.name]?s.selected=!0:"INPUT"===s.nodeName&&"value"===t[n._const.name]&&(s.value=t[n._const.value]);break;case n._const.modifyAttribute:s.attributes[t[n._const.name]]=t[n._const.newValue];break;case n._const.removeAttribute:delete s.attributes[t[n._const.name]],0===Object.keys(s.attributes).length&&delete s.attributes,"checked"===t[n._const.name]?s.checked=!1:"selected"===t[n._const.name]?delete s.selected:"INPUT"===s.nodeName&&"value"===t[n._const.name]&&delete s.value;break;case n._const.modifyTextElement:s.data=t[n._const.newValue],"TEXTAREA"===i.nodeName&&(i.value=t[n._const.newValue]);break;case n._const.modifyValue:s.value=t[n._const.newValue];break;case n._const.modifyComment:s.data=t[n._const.newValue];break;case n._const.modifyChecked:s.checked=t[n._const.newValue];break;case n._const.modifySelected:s.selected=t[n._const.newValue];break;case n._const.replaceElement:c=h(t[n._const.newValue]),i.childNodes[a]=c;break;case n._const.relocateGroup:s.childNodes.splice(t[n._const.from],t[n._const.groupLength]).reverse().forEach((function(e){return s.childNodes.splice(t[n._const.to],0,e)})),s.subsets&&s.subsets.forEach((function(e){if(t[n._const.from]<t[n._const.to]&&e.oldValue<=t[n._const.to]&&e.oldValue>t[n._const.from])e.oldValue-=t[n._const.groupLength],(o=e.oldValue+e.length-t[n._const.to])>0&&(u.push({oldValue:t[n._const.to]+t[n._const.groupLength],newValue:e.newValue+e.length-o,length:o}),e.length-=o);else if(t[n._const.from]>t[n._const.to]&&e.oldValue>t[n._const.to]&&e.oldValue<t[n._const.from]){var o;e.oldValue+=t[n._const.groupLength],(o=e.oldValue+e.length-t[n._const.to])>0&&(u.push({oldValue:t[n._const.to]+t[n._const.groupLength],newValue:e.newValue+e.length-o,length:o}),e.length-=o)}else e.oldValue===t[n._const.from]&&(e.oldValue=t[n._const.to])}));break;case n._const.removeElement:i.childNodes.splice(a,1),i.subsets&&i.subsets.forEach((function(e){e.oldValue>a?e.oldValue-=1:e.oldValue===a?e.delete=!0:e.oldValue<a&&e.oldValue+e.length>a&&(e.oldValue+e.length-1===a?e.length--:(u.push({newValue:e.newValue+a-e.oldValue,oldValue:a,length:e.length-a+e.oldValue-1}),e.length=a-e.oldValue))})),s=i;break;case n._const.addElement:var p=(r=t[n._const.route].slice()).splice(r.length-1,1)[0];s=null===(o=g(e,r))||void 0===o?void 0:o.node,c=h(t[n._const.element]),s.childNodes||(s.childNodes=[]),p>=s.childNodes.length?s.childNodes.push(c):s.childNodes.splice(p,0,c),s.subsets&&s.subsets.forEach((function(e){if(e.oldValue>=p)e.oldValue+=1;else if(e.oldValue<p&&e.oldValue+e.length>p){var t=e.oldValue+e.length-p;u.push({newValue:e.newValue+e.length-t,oldValue:p+1,length:t}),e.length-=t}}));break;case n._const.removeTextElement:i.childNodes.splice(a,1),"TEXTAREA"===i.nodeName&&delete i.value,i.subsets&&i.subsets.forEach((function(e){e.oldValue>a?e.oldValue-=1:e.oldValue===a?e.delete=!0:e.oldValue<a&&e.oldValue+e.length>a&&(e.oldValue+e.length-1===a?e.length--:(u.push({newValue:e.newValue+a-e.oldValue,oldValue:a,length:e.length-a+e.oldValue-1}),e.length=a-e.oldValue))})),s=i;break;case n._const.addTextElement:var f=(r=t[n._const.route].slice()).splice(r.length-1,1)[0];c={nodeName:"#text",data:t[n._const.value]},(s=g(e,r).node).childNodes||(s.childNodes=[]),f>=s.childNodes.length?s.childNodes.push(c):s.childNodes.splice(f,0,c),"TEXTAREA"===s.nodeName&&(s.value=t[n._const.newValue]),s.subsets&&s.subsets.forEach((function(e){if(e.oldValue>=f&&(e.oldValue+=1),e.oldValue<f&&e.oldValue+e.length>f){var t=e.oldValue+e.length-f;u.push({newValue:e.newValue+e.length-t,oldValue:f+1,length:t}),e.length-=t}}));break;default:console.log("unknown action")}s.subsets&&(s.subsets=s.subsets.filter((function(e){return!e.delete&&e.oldValue!==e.newValue})),u.length&&(s.subsets=s.subsets.concat(u))),n.postVirtualDiffApply({node:d.node,diff:d.diff,newNode:c})}(e,t,n)})),!0}function b(e,n){void 0===n&&(n={valueDiffing:!0});var o={nodeName:e.nodeName};if(t(e,"Text","Comment"))o.data=e.data;else{if(e.attributes&&e.attributes.length>0)o.attributes={},Array.prototype.slice.call(e.attributes).forEach((function(e){return o.attributes[e.name]=e.value}));if(e.childNodes&&e.childNodes.length>0)o.childNodes=[],Array.prototype.slice.call(e.childNodes).forEach((function(e){return o.childNodes.push(b(e,n))}));n.valueDiffing&&(t(e,"HTMLTextAreaElement")&&(o.value=e.value),t(e,"HTMLInputElement")&&["radio","checkbox"].includes(e.type.toLowerCase())&&void 0!==e.checked?o.checked=e.checked:t(e,"HTMLButtonElement","HTMLDataElement","HTMLInputElement","HTMLLIElement","HTMLMeterElement","HTMLOptionElement","HTMLProgressElement","HTMLParamElement")&&(o.value=e.value),t(e,"HTMLOptionElement")&&(o.selected=e.selected))}return o}var N=/<\s*\/*[a-zA-Z:_][a-zA-Z0-9:_\-.]*\s*(?:"[^"]*"['"]*|'[^']*'['"]*|[^'"/>])*\/*\s*>|<!--(?:.|\n|\r)*?-->/g,y=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function w(e){return e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&")}var E={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,menuItem:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},k=function(e,t){var n={nodeName:"",attributes:{}},o=!1,s=e.match(/<\/?([^\s]+?)[/\s>]/);if(s&&(n.nodeName=t||"svg"===s[1]?s[1]:s[1].toUpperCase(),(E[s[1]]||"/"===e.charAt(e.length-2))&&(o=!0),n.nodeName.startsWith("!--"))){var i=e.indexOf("--\x3e");return{type:"comment",node:{nodeName:"#comment",data:-1!==i?e.slice(4,i):""},voidElement:o}}for(var a=new RegExp(y),l=null,c=!1;!c;)if(null===(l=a.exec(e)))c=!0;else if(l[0].trim())if(l[1]){var r=l[1].trim(),u=[r,""];r.indexOf("=")>-1&&(u=r.split("=")),n.attributes[u[0]]=u[1],a.lastIndex--}else l[2]&&(n.attributes[l[2]]=l[3].trim().substring(1,l[3].length-1));return{type:"tag",node:n,voidElement:o}},x=function(e,t){void 0===t&&(t={valueDiffing:!0,caseSensitive:!1});var n,o=[],s=-1,i=[],a=!1;if(0!==e.indexOf("<")){var l=e.indexOf("<");o.push({nodeName:"#text",data:-1===l?e:e.substring(0,l)})}return e.replace(N,(function(l,c){var r="/"!==l.charAt(1),u=l.startsWith("\x3c!--"),d=c+l.length,h=e.charAt(d);if(u){var p=k(l,t.caseSensitive).node;if(s<0)return o.push(p),"";var f=i[s];return f&&p.nodeName&&(f.node.childNodes||(f.node.childNodes=[]),f.node.childNodes.push(p)),""}if(r){if("svg"===(n=k(l,t.caseSensitive||a)).node.nodeName&&(a=!0),s++,!n.voidElement&&h&&"<"!==h){n.node.childNodes||(n.node.childNodes=[]);var m=w(e.slice(d,e.indexOf("<",d)));n.node.childNodes.push({nodeName:"#text",data:m}),t.valueDiffing&&"TEXTAREA"===n.node.nodeName&&(n.node.value=m)}0===s&&n.node.nodeName&&o.push(n.node);var _=i[s-1];_&&n.node.nodeName&&(_.node.childNodes||(_.node.childNodes=[]),_.node.childNodes.push(n.node)),i[s]=n}if((!r||n.voidElement)&&(s>-1&&(n.voidElement||t.caseSensitive&&n.node.nodeName===l.slice(2,-1)||!t.caseSensitive&&n.node.nodeName.toUpperCase()===l.slice(2,-1).toUpperCase())&&--s>-1&&("svg"===n.node.nodeName&&(a=!1),n=i[s]),"<"!==h&&h)){var v=-1===s?o:i[s].node.childNodes||[],g=e.indexOf("<",d);m=w(e.slice(d,-1===g?void 0:g));v.push({nodeName:"#text",data:m})}return""})),o[0]},T=function(){function n(e,n,o){this.options=o,this.t1="undefined"!=typeof Element&&t(e,"Element")?b(e,this.options):"string"==typeof e?x(e,this.options):JSON.parse(JSON.stringify(e)),this.t2="undefined"!=typeof Element&&t(n,"Element")?b(n,this.options):"string"==typeof n?x(n,this.options):JSON.parse(JSON.stringify(n)),this.diffcount=0,this.foundAll=!1,this.debug&&(this.t1Orig="undefined"!=typeof Element&&t(e,"Element")?b(e,this.options):"string"==typeof e?x(e,this.options):JSON.parse(JSON.stringify(e)),this.t2Orig="undefined"!=typeof Element&&t(n,"Element")?b(n,this.options):"string"==typeof n?x(n,this.options):JSON.parse(JSON.stringify(n))),this.tracker=new v}return n.prototype.init=function(){return this.findDiffs(this.t1,this.t2)},n.prototype.findDiffs=function(e,t){var n;do{if(this.options.debug&&(this.diffcount+=1,this.diffcount>this.options.diffcap))throw new Error("surpassed diffcap:".concat(JSON.stringify(this.t1Orig)," -> ").concat(JSON.stringify(this.t2Orig)));0===(n=this.findNextDiff(e,t,[])).length&&(p(e,t)||(this.foundAll?console.error("Could not find remaining diffs!"):(this.foundAll=!0,d(e),n=this.findNextDiff(e,t,[])))),n.length>0&&(this.foundAll=!1,this.tracker.add(n),V(e,n,this.options))}while(n.length>0);return this.tracker.list},n.prototype.findNextDiff=function(e,t,n){var o,s;if(this.options.maxDepth&&n.length>this.options.maxDepth)return[];if(!e.outerDone){if(o=this.findOuterDiff(e,t,n),this.options.filterOuterDiff&&(s=this.options.filterOuterDiff(e,t,o))&&(o=s),o.length>0)return e.outerDone=!0,o;e.outerDone=!0}if(Object.prototype.hasOwnProperty.call(e,"data"))return[];if(!e.innerDone){if((o=this.findInnerDiff(e,t,n)).length>0)return o;e.innerDone=!0}if(this.options.valueDiffing&&!e.valueDone){if((o=this.findValueDiff(e,t,n)).length>0)return e.valueDone=!0,o;e.valueDone=!0}return[]},n.prototype.findOuterDiff=function(t,n,o){var s,i,a,l,c,r,u=[];if(t.nodeName!==n.nodeName){if(!o.length)throw new Error("Top level nodes have to be of the same kind.");return[(new e).setValue(this.options._const.action,this.options._const.replaceElement).setValue(this.options._const.oldValue,h(t)).setValue(this.options._const.newValue,h(n)).setValue(this.options._const.route,o)]}if(o.length&&this.options.diffcap<Math.abs((t.childNodes||[]).length-(n.childNodes||[]).length))return[(new e).setValue(this.options._const.action,this.options._const.replaceElement).setValue(this.options._const.oldValue,h(t)).setValue(this.options._const.newValue,h(n)).setValue(this.options._const.route,o)];if(Object.prototype.hasOwnProperty.call(t,"data")&&t.data!==n.data)return"#text"===t.nodeName?[(new e).setValue(this.options._const.action,this.options._const.modifyTextElement).setValue(this.options._const.route,o).setValue(this.options._const.oldValue,t.data).setValue(this.options._const.newValue,n.data)]:[(new e).setValue(this.options._const.action,this.options._const.modifyComment).setValue(this.options._const.route,o).setValue(this.options._const.oldValue,t.data).setValue(this.options._const.newValue,n.data)];for(i=t.attributes?Object.keys(t.attributes).sort():[],a=n.attributes?Object.keys(n.attributes).sort():[],l=i.length,r=0;r<l;r++)s=i[r],-1===(c=a.indexOf(s))?u.push((new e).setValue(this.options._const.action,this.options._const.removeAttribute).setValue(this.options._const.route,o).setValue(this.options._const.name,s).setValue(this.options._const.value,t.attributes[s])):(a.splice(c,1),t.attributes[s]!==n.attributes[s]&&u.push((new e).setValue(this.options._const.action,this.options._const.modifyAttribute).setValue(this.options._const.route,o).setValue(this.options._const.name,s).setValue(this.options._const.oldValue,t.attributes[s]).setValue(this.options._const.newValue,n.attributes[s])));for(l=a.length,r=0;r<l;r++)s=a[r],u.push((new e).setValue(this.options._const.action,this.options._const.addAttribute).setValue(this.options._const.route,o).setValue(this.options._const.name,s).setValue(this.options._const.value,n.attributes[s]));return u},n.prototype.findInnerDiff=function(t,n,o){var s=t.childNodes?t.childNodes.slice():[],i=n.childNodes?n.childNodes.slice():[],a=Math.max(s.length,i.length),l=Math.abs(s.length-i.length),c=[],r=0;if(!this.options.maxChildCount||a<this.options.maxChildCount){var u=Boolean(t.subsets&&t.subsetsAge--),d=u?t.subsets:t.childNodes&&n.childNodes?_(t,n):[];if(d.length>0&&(c=this.attemptGroupRelocation(t,n,d,o,u)).length>0)return c}for(var f=0;f<a;f+=1){var m=s[f],v=i[f];l&&(m&&!v?"#text"===m.nodeName?(c.push((new e).setValue(this.options._const.action,this.options._const.removeTextElement).setValue(this.options._const.route,o.concat(r)).setValue(this.options._const.value,m.data)),r-=1):(c.push((new e).setValue(this.options._const.action,this.options._const.removeElement).setValue(this.options._const.route,o.concat(r)).setValue(this.options._const.element,h(m))),r-=1):v&&!m&&("#text"===v.nodeName?c.push((new e).setValue(this.options._const.action,this.options._const.addTextElement).setValue(this.options._const.route,o.concat(r)).setValue(this.options._const.value,v.data)):c.push((new e).setValue(this.options._const.action,this.options._const.addElement).setValue(this.options._const.route,o.concat(r)).setValue(this.options._const.element,h(v))))),m&&v&&(!this.options.maxChildCount||a<this.options.maxChildCount?c=c.concat(this.findNextDiff(m,v,o.concat(r))):p(m,v)||(s.length>i.length?("#text"===m.nodeName?c.push((new e).setValue(this.options._const.action,this.options._const.removeTextElement).setValue(this.options._const.route,o.concat(r)).setValue(this.options._const.value,m.data)):c.push((new e).setValue(this.options._const.action,this.options._const.removeElement).setValue(this.options._const.element,h(m)).setValue(this.options._const.route,o.concat(r))),s.splice(f,1),f-=1,r-=1,l-=1):s.length<i.length?(c=c.concat([(new e).setValue(this.options._const.action,this.options._const.addElement).setValue(this.options._const.element,h(v)).setValue(this.options._const.route,o.concat(r))]),s.splice(f,0,h(v)),l-=1):c=c.concat([(new e).setValue(this.options._const.action,this.options._const.replaceElement).setValue(this.options._const.oldValue,h(m)).setValue(this.options._const.newValue,h(v)).setValue(this.options._const.route,o.concat(r))]))),r+=1}return t.innerDone=!0,c},n.prototype.attemptGroupRelocation=function(t,n,o,s,i){for(var a,l,c,r,u,d=function(e,t,n){var o=e.childNodes?m(e.childNodes.length,!0):[],s=t.childNodes?m(t.childNodes.length,!0):[],i=0;return n.forEach((function(e){for(var t=e.oldValue+e.length,n=e.newValue+e.length,a=e.oldValue;a<t;a+=1)o[a]=i;for(a=e.newValue;a<n;a+=1)s[a]=i;i+=1})),{gaps1:o,gaps2:s}}(t,n,o),p=d.gaps1,_=d.gaps2,v=t.childNodes.slice(),g=n.childNodes.slice(),V=Math.min(p.length,_.length),b=[],N=0,y=0;N<V;y+=1,N+=1)if(!i||!0!==p[N]&&!0!==_[N]){if(!0===p[y])if("#text"===(r=v[y]).nodeName)if("#text"===g[N].nodeName){if(r.data!==g[N].data){for(var w=y;v.length>w+1&&"#text"===v[w+1].nodeName;)if(w+=1,g[N].data===v[w].data){u=!0;break}u||b.push((new e).setValue(this.options._const.action,this.options._const.modifyTextElement).setValue(this.options._const.route,s.concat(y)).setValue(this.options._const.oldValue,r.data).setValue(this.options._const.newValue,g[N].data))}}else b.push((new e).setValue(this.options._const.action,this.options._const.removeTextElement).setValue(this.options._const.route,s.concat(y)).setValue(this.options._const.value,r.data)),p.splice(y,1),v.splice(y,1),V=Math.min(p.length,_.length),y-=1,N-=1;else!0===_[N]?b.push((new e).setValue(this.options._const.action,this.options._const.replaceElement).setValue(this.options._const.oldValue,h(r)).setValue(this.options._const.newValue,h(g[N])).setValue(this.options._const.route,s.concat(y))):(b.push((new e).setValue(this.options._const.action,this.options._const.removeElement).setValue(this.options._const.route,s.concat(y)).setValue(this.options._const.element,h(r))),p.splice(y,1),v.splice(y,1),V=Math.min(p.length,_.length),y-=1,N-=1);else if(!0===_[N])"#text"===(r=g[N]).nodeName?(b.push((new e).setValue(this.options._const.action,this.options._const.addTextElement).setValue(this.options._const.route,s.concat(y)).setValue(this.options._const.value,r.data)),p.splice(y,0,!0),v.splice(y,0,{nodeName:"#text",data:r.data}),V=Math.min(p.length,_.length)):(b.push((new e).setValue(this.options._const.action,this.options._const.addElement).setValue(this.options._const.route,s.concat(y)).setValue(this.options._const.element,h(r))),p.splice(y,0,!0),v.splice(y,0,h(r)),V=Math.min(p.length,_.length));else if(p[y]!==_[N]){if(b.length>0)return b;if(c=o[p[y]],(l=Math.min(c.newValue,v.length-c.length))!==c.oldValue){a=!1;for(var E=0;E<c.length;E+=1)f(v[l+E],v[c.oldValue+E],{},!1,!0)||(a=!0);if(a)return[(new e).setValue(this.options._const.action,this.options._const.relocateGroup).setValue(this.options._const.groupLength,c.length).setValue(this.options._const.from,c.oldValue).setValue(this.options._const.to,l).setValue(this.options._const.route,s)]}}}else;return b},n.prototype.findValueDiff=function(t,n,o){var s=[];return t.selected!==n.selected&&s.push((new e).setValue(this.options._const.action,this.options._const.modifySelected).setValue(this.options._const.oldValue,t.selected).setValue(this.options._const.newValue,n.selected).setValue(this.options._const.route,o)),(t.value||n.value)&&t.value!==n.value&&"OPTION"!==t.nodeName&&s.push((new e).setValue(this.options._const.action,this.options._const.modifyValue).setValue(this.options._const.oldValue,t.value||"").setValue(this.options._const.newValue,n.value||"").setValue(this.options._const.route,o)),t.checked!==n.checked&&s.push((new e).setValue(this.options._const.action,this.options._const.modifyChecked).setValue(this.options._const.oldValue,t.checked).setValue(this.options._const.newValue,n.checked).setValue(this.options._const.route,o)),s},n}(),O={debug:!1,diffcap:10,maxDepth:!1,maxChildCount:50,valueDiffing:!0,textDiff:function(e,t,n,o){e.data=o},preVirtualDiffApply:function(){},postVirtualDiffApply:function(){},preDiffApply:function(){},postDiffApply:function(){},filterOuterDiff:null,compress:!1,_const:!1,document:!("undefined"==typeof window||!window.document)&&window.document,components:[]},A=function(){function e(e){if(void 0===e&&(e={}),Object.entries(O).forEach((function(t){var n=t[0],o=t[1];Object.prototype.hasOwnProperty.call(e,n)||(e[n]=o)})),!e._const){var t=["addAttribute","modifyAttribute","removeAttribute","modifyTextElement","relocateGroup","removeElement","addElement","removeTextElement","addTextElement","replaceElement","modifyValue","modifyChecked","modifySelected","modifyComment","action","route","oldValue","newValue","element","group","groupLength","from","to","name","value","data","attributes","nodeName","childNodes","checked","selected"],n={};e.compress?t.forEach((function(e,t){return n[e]=t})):t.forEach((function(e){return n[e]=e})),e._const=n}this.options=e}return e.prototype.apply=function(e,t){return function(e,t,n){return t.every((function(t){return s(e,t,n)}))}(e,t,this.options)},e.prototype.undo=function(e,t){return a(e,t,this.options)},e.prototype.diff=function(e,t){return new T(e,t,this.options).init()},e}(),D=function(){function e(e){var t=this;void 0===e&&(e={}),this.pad="│ ",this.padding="",this.tick=1,this.messages=[];var n=function(e,n){var o=e[n];e[n]=function(){for(var s=arguments,i=[],a=0;a<arguments.length;a++)i[a]=s[a];t.fin(n,Array.prototype.slice.call(i));var l=o.apply(e,i);return t.fout(n,l),l}};for(var o in e)"function"==typeof e[o]&&n(e,o);this.log("┌ TRACELOG START")}return e.prototype.fin=function(e,t){this.padding+=this.pad,this.log("├─> entering ".concat(e),t)},e.prototype.fout=function(e,t){this.log("│<──┘ generated return value",t),this.padding=this.padding.substring(0,this.padding.length-this.pad.length)},e.prototype.format=function(e,t){return"".concat(function(e){for(var t="".concat(e);t.length<4;)t="0".concat(e);return t}(t),"> ").concat(this.padding).concat(e)},e.prototype.log=function(){for(var e=arguments,n=[],o=0;o<arguments.length;o++)n[o]=e[o];var s=function(e){return e?"string"==typeof e?e:t(e,"HTMLElement")?e.outerHTML||"<empty>":e instanceof Array?"[".concat(e.map(s).join(","),"]"):e.toString()||e.valueOf()||"<unknown>":"<falsey>"},i=n.map(s).join(", ");this.messages.push(this.format(i,this.tick++))},e.prototype.toString=function(){for(var e="└───";e.length<=this.padding.length+this.pad.length;)e+="× ";var t=this.padding;return this.padding="",e=this.format(e,this.tick),this.padding=t,"".concat(this.messages.join("\n"),"\n").concat(e)},e}();exports.DiffDOM=A,exports.TraceLogger=D,exports.nodeToObj=b,exports.stringToObj=x;
//# sourceMappingURL=index.min.js.map
{
"name": "diff-dom",
"version": "5.1.0",
"version": "5.1.1",
"description": "A diff for DOM elements, as client-side JavaScript code. Gets all modifications, insertions and removals between two DOM fragments.",

@@ -39,17 +39,17 @@ "main": "dist/index.js",

"@rollup/plugin-buble": "^1.0.1",
"@rollup/plugin-terser": "^0.3.0",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.0.0",
"@typescript-eslint/eslint-plugin": "^5.48.1",
"@typescript-eslint/parser": "^5.48.1",
"@typescript-eslint/eslint-plugin": "^6.11.0",
"@typescript-eslint/parser": "^6.11.0",
"eslint": "^8.26.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.1",
"jest": "^29.3.1",
"jest-environment-jsdom": "^29.2.2",
"prettier": "^2.7.1",
"rollup": "^3.10.0",
"rollup-plugin-dts": "^5.1.1",
"prettier": "^3.1.0",
"rollup": "^4.4.1",
"rollup-plugin-dts": "^6.1.0",
"tslib": "^2.5.0",
"updates": "^13.1.13"
"updates": "^15.0.4"
}
}
import { DiffDOMOptions, diffType, nodeType } from "../types"
import { Diff } from "../helpers"
import { Diff, checkElementType } from "../helpers"

@@ -10,3 +10,3 @@ import { objToNode } from "./fromVirtual"

node: Element,
route: number[]
route: number[],
): Element | Text | false => {

@@ -24,3 +24,3 @@ route = route.slice()

diff: diffType,
options: DiffDOMOptions // {preDiffApply, postDiffApply, textDiff, valueDiffing, _const}
options: DiffDOMOptions, // {preDiffApply, postDiffApply, textDiff, valueDiffing, _const}
) {

@@ -33,3 +33,3 @@ const action = diff[options._const.action] as string | number

![options._const.addElement, options._const.addTextElement].includes(
action
action,
)

@@ -57,3 +57,3 @@ ) {

case options._const.addAttribute:
if (!node || !(node instanceof Element)) {
if (!node || !checkElementType(node, "Element")) {
return false

@@ -63,7 +63,7 @@ }

diff[options._const.name] as string,
diff[options._const.value] as string
diff[options._const.value] as string,
)
break
case options._const.modifyAttribute:
if (!node || !(node instanceof Element)) {
if (!node || !checkElementType(node, "Element")) {
return false

@@ -73,6 +73,6 @@ }

diff[options._const.name] as string,
diff[options._const.newValue] as string
diff[options._const.newValue] as string,
)
if (
node instanceof HTMLInputElement &&
checkElementType(node, "HTMLInputElement") &&
diff[options._const.name] === "value"

@@ -84,3 +84,3 @@ ) {

case options._const.removeAttribute:
if (!node || !(node instanceof Element)) {
if (!node || !checkElementType(node, "Element")) {
return false

@@ -91,3 +91,3 @@ }

case options._const.modifyTextElement:
if (!node || !(node instanceof Text)) {
if (!node || !checkElementType(node, "Text")) {
return false

@@ -99,5 +99,5 @@ }

diff[options._const.oldValue] as string,
diff[options._const.newValue] as string
diff[options._const.newValue] as string,
)
if (node.parentNode instanceof HTMLTextAreaElement) {
if (checkElementType(node.parentNode, "HTMLTextAreaElement")) {
node.parentNode.value = diff[options._const.newValue] as string

@@ -113,3 +113,3 @@ }

case options._const.modifyComment:
if (!node || !(node instanceof Comment)) {
if (!node || !checkElementType(node, "Comment")) {
return false

@@ -121,3 +121,3 @@ }

diff[options._const.oldValue] as string,
diff[options._const.newValue] as string
diff[options._const.newValue] as string,
)

@@ -147,5 +147,5 @@ break

insideSvg,
options
options,
),
node
node,
)

@@ -156,7 +156,7 @@ break

nodeArray = Array(
...new Array(diff[options._const.groupLength])
...new Array(diff[options._const.groupLength]),
).map(() =>
node.removeChild(
node.childNodes[diff[options._const.from] as number]
)
node.childNodes[diff[options._const.from] as number],
),
)

@@ -178,3 +178,3 @@ nodeArray.forEach((childNode, index) => {

node = getFromRoute(tree, parentRoute)
if (!(node instanceof Element)) {
if (!checkElementType(node, "Element")) {
return false

@@ -186,5 +186,5 @@ }

node.namespaceURI === "http://www.w3.org/2000/svg",
options
options,
),
node.childNodes[c] || null
node.childNodes[c] || null,
)

@@ -199,3 +199,3 @@ break

parentNode.removeChild(node)
if (parentNode instanceof HTMLTextAreaElement) {
if (checkElementType(parentNode, "HTMLTextAreaElement")) {
parentNode.value = ""

@@ -209,3 +209,3 @@ }

newNode = options.document.createTextNode(
diff[options._const.value] as string
diff[options._const.value] as string,
)

@@ -217,3 +217,3 @@ node = getFromRoute(tree, parentRoute)

node.insertBefore(newNode, node.childNodes[c] || null)
if (node.parentNode instanceof HTMLTextAreaElement) {
if (checkElementType(node.parentNode, "HTMLTextAreaElement")) {
node.parentNode.value = diff[options._const.value] as string

@@ -241,7 +241,7 @@ }

diffs: (Diff | diffType)[],
options: DiffDOMOptions
options: DiffDOMOptions,
) {
return diffs.every((diff: Diff | diffType) =>
applyDiff(tree, diff as diffType, options)
applyDiff(tree, diff as diffType, options),
)
}
import { DiffDOMOptions, elementNodeType, textNodeType } from "../types"
import { checkElementType } from "../helpers"

@@ -6,3 +7,3 @@ export function objToNode(

insideSvg: boolean,
options: DiffDOMOptions
options: DiffDOMOptions,
) {

@@ -18,3 +19,3 @@ let node: Element | Text | Comment

"http://www.w3.org/2000/svg",
objNode.nodeName
objNode.nodeName,
)

@@ -24,3 +25,3 @@ } else if (objNode.nodeName.toLowerCase() === "svg") {

"http://www.w3.org/2000/svg",
"svg"
"svg",
)

@@ -33,3 +34,3 @@ insideSvg = true

Object.entries(objNode.attributes).forEach(([key, value]) =>
(node as Element).setAttribute(key, value)
(node as Element).setAttribute(key, value),
)

@@ -41,3 +42,3 @@ }

(childNode: elementNodeType | textNodeType) =>
node.appendChild(objToNode(childNode, insideSvg, options))
node.appendChild(objToNode(childNode, insideSvg, options)),
)

@@ -48,18 +49,34 @@ }

objNode.value &&
(node instanceof HTMLButtonElement ||
node instanceof HTMLDataElement ||
node instanceof HTMLInputElement ||
node instanceof HTMLLIElement ||
node instanceof HTMLMeterElement ||
node instanceof HTMLOptionElement ||
node instanceof HTMLProgressElement ||
node instanceof HTMLParamElement)
checkElementType(
node,
"HTMLButtonElement",
"HTMLDataElement",
"HTMLInputElement",
"HTMLLIElement",
"HTMLMeterElement",
"HTMLOptionElement",
"HTMLProgressElement",
"HTMLParamElement",
)
) {
node.value = objNode.value
;(
node as
| HTMLButtonElement
| HTMLDataElement
| HTMLInputElement
| HTMLLIElement
| HTMLMeterElement
| HTMLOptionElement
| HTMLProgressElement
| HTMLParamElement
).value = objNode.value
}
if (objNode.checked && node instanceof HTMLInputElement) {
node.checked = objNode.checked
if (objNode.checked && checkElementType(node, "HTMLInputElement")) {
;(node as HTMLInputElement).checked = objNode.checked
}
if (objNode.selected && node instanceof HTMLOptionElement) {
node.selected = objNode.selected
if (
objNode.selected &&
checkElementType(node, "HTMLOptionElement")
) {
;(node as HTMLOptionElement).selected = objNode.selected
}

@@ -66,0 +83,0 @@ }

@@ -16,3 +16,3 @@ import { DiffDOMOptions, diffType } from "../types"

diff: diffType,
options: DiffDOMOptions // {preDiffApply, postDiffApply, textDiff, valueDiffing, _const}
options: DiffDOMOptions, // {preDiffApply, postDiffApply, textDiff, valueDiffing, _const}
) {

@@ -84,3 +84,3 @@ switch (diff[options._const.action]) {

diffs: (diffType | Diff)[],
options: DiffDOMOptions
options: DiffDOMOptions,
) {

@@ -87,0 +87,0 @@ diffs = diffs.slice()

@@ -20,3 +20,3 @@ import { elementNodeType } from "./types"

| { [key: string]: string | { [key: string]: string } }
| elementNodeType
| elementNodeType,
) {

@@ -27,1 +27,17 @@ this[aKey] = aValue

}
export const checkElementType = (element, ...elementTypeNames: string[]) => {
if (typeof element === "undefined" || element === null) {
return false
}
// Use by default the global scope from node.js, with a fallback on the node's parent window,
// or the current window (for web browser environment).
const scope = global || element?.ownerDocument?.defaultView || window
return elementTypeNames.some(
(elementTypeName) =>
// We need to check if the specified type is defined in the given scope
// because otherwise instanceof throws an exception.
typeof scope?.[elementTypeName] === "function" &&
element instanceof scope[elementTypeName],
)
}

@@ -26,3 +26,3 @@ import {

expectedValue: string,
newValue: string
newValue: string,
) {

@@ -96,3 +96,3 @@ node.data = newValue

varNames.forEach(
(varName, index) => (constNames[varName] = index)
(varName, index) => (constNames[varName] = index),
)

@@ -118,3 +118,3 @@ } else {

t1Node: string | elementNodeType | Element,
t2Node: string | elementNodeType | Element
t2Node: string | elementNodeType | Element,
) {

@@ -121,0 +121,0 @@ const finder = new DiffFinder(t1Node, t2Node, this.options)

@@ -114,3 +114,3 @@ import { Diff } from "./helpers"

expectedValue: string,
newValue: string
newValue: string,
) => void

@@ -117,0 +117,0 @@ preVirtualDiffApply: PreDiffApply

@@ -27,3 +27,3 @@ import { DiffDOMOptions, elementNodeType, nodeType, subsetType } from "../types"

diff: Diff,
options: DiffDOMOptions // {preVirtualDiffApply, postVirtualDiffApply, _const}
options: DiffDOMOptions, // {preVirtualDiffApply, postVirtualDiffApply, _const}
) {

@@ -34,3 +34,3 @@ let node, parentNode, nodeIndex

![options._const.addElement, options._const.addTextElement].includes(
diff[options._const.action]
diff[options._const.action],
)

@@ -131,7 +131,7 @@ ) {

diff[options._const.from],
diff[options._const.groupLength]
diff[options._const.groupLength],
)
.reverse()
nodeArray.forEach((movedNode: nodeType) =>
node.childNodes.splice(diff[options._const.to], 0, movedNode)
node.childNodes.splice(diff[options._const.to], 0, movedNode),
)

@@ -327,3 +327,3 @@ if (node.subsets) {

node.subsets = node.subsets.filter(
(map: subsetType) => !map.delete && map.oldValue !== map.newValue
(map: subsetType) => !map.delete && map.oldValue !== map.newValue,
)

@@ -347,3 +347,3 @@ if (newSubsets.length) {

diffs: Diff[],
options: DiffDOMOptions
options: DiffDOMOptions,
) {

@@ -350,0 +350,0 @@ diffs.forEach((diff: Diff) => {

@@ -18,3 +18,3 @@ import {

} from "./helpers"
import { Diff } from "../helpers"
import { Diff, checkElementType } from "../helpers"
import { applyVirtual } from "./apply"

@@ -39,18 +39,20 @@ import { nodeToObj } from "./fromDOM"

t2Node: string | elementNodeType | Element,
options: DiffDOMOptions
options: DiffDOMOptions,
) {
this.options = options
this.t1 = (
typeof Element !== "undefined" && t1Node instanceof Element
? nodeToObj(t1Node, this.options)
typeof Element !== "undefined" &&
checkElementType(t1Node, "Element")
? nodeToObj(t1Node as Element, this.options)
: typeof t1Node === "string"
? stringToObj(t1Node, this.options)
: JSON.parse(JSON.stringify(t1Node))
? stringToObj(t1Node, this.options)
: JSON.parse(JSON.stringify(t1Node))
) as elementDiffNodeType
this.t2 = (
typeof Element !== "undefined" && t2Node instanceof Element
? nodeToObj(t2Node, this.options)
typeof Element !== "undefined" &&
checkElementType(t2Node, "Element")
? nodeToObj(t2Node as Element, this.options)
: typeof t2Node === "string"
? stringToObj(t2Node, this.options)
: JSON.parse(JSON.stringify(t2Node))
? stringToObj(t2Node, this.options)
: JSON.parse(JSON.stringify(t2Node))
) as elementDiffNodeType

@@ -61,13 +63,15 @@ this.diffcount = 0

this.t1Orig =
typeof Element !== "undefined" && t1Node instanceof Element
? nodeToObj(t1Node, this.options)
typeof Element !== "undefined" &&
checkElementType(t1Node, "Element")
? nodeToObj(t1Node as Element, this.options)
: typeof t1Node === "string"
? stringToObj(t1Node, this.options)
: JSON.parse(JSON.stringify(t1Node))
? stringToObj(t1Node, this.options)
: JSON.parse(JSON.stringify(t1Node))
this.t2Orig =
typeof Element !== "undefined" && t2Node instanceof Element
? nodeToObj(t2Node, this.options)
typeof Element !== "undefined" &&
checkElementType(t2Node, "Element")
? nodeToObj(t2Node as Element, this.options)
: typeof t2Node === "string"
? stringToObj(t2Node, this.options)
: JSON.parse(JSON.stringify(t2Node))
? stringToObj(t2Node, this.options)
: JSON.parse(JSON.stringify(t2Node))
}

@@ -90,4 +94,4 @@

`surpassed diffcap:${JSON.stringify(
this.t1Orig
)} -> ${JSON.stringify(this.t2Orig)}`
this.t1Orig,
)} -> ${JSON.stringify(this.t2Orig)}`,
)

@@ -192,3 +196,3 @@ }

this.options._const.action,
this.options._const.replaceElement
this.options._const.replaceElement,
)

@@ -204,3 +208,3 @@ .setValue(this.options._const.oldValue, cleanNode(t1))

Math.abs(
(t1.childNodes || []).length - (t2.childNodes || []).length
(t1.childNodes || []).length - (t2.childNodes || []).length,
)

@@ -212,3 +216,3 @@ ) {

this.options._const.action,
this.options._const.replaceElement
this.options._const.replaceElement,
)

@@ -231,3 +235,3 @@ .setValue(this.options._const.oldValue, cleanNode(t1))

this.options._const.action,
this.options._const.modifyTextElement
this.options._const.modifyTextElement,
)

@@ -237,7 +241,7 @@ .setValue(this.options._const.route, route)

this.options._const.oldValue,
(t1 as textDiffNodeType).data
(t1 as textDiffNodeType).data,
)
.setValue(
this.options._const.newValue,
(t2 as textDiffNodeType).data
(t2 as textDiffNodeType).data,
),

@@ -250,3 +254,3 @@ ]

this.options._const.action,
this.options._const.modifyComment
this.options._const.modifyComment,
)

@@ -256,7 +260,7 @@ .setValue(this.options._const.route, route)

this.options._const.oldValue,
(t1 as textDiffNodeType).data
(t1 as textDiffNodeType).data,
)
.setValue(
this.options._const.newValue,
(t2 as textDiffNodeType).data
(t2 as textDiffNodeType).data,
),

@@ -282,3 +286,3 @@ ]

this.options._const.action,
this.options._const.removeAttribute
this.options._const.removeAttribute,
)

@@ -289,4 +293,4 @@ .setValue(this.options._const.route, route)

this.options._const.value,
t1.attributes[attr]
)
t1.attributes[attr],
),
)

@@ -300,3 +304,3 @@ } else {

this.options._const.action,
this.options._const.modifyAttribute
this.options._const.modifyAttribute,
)

@@ -307,8 +311,8 @@ .setValue(this.options._const.route, route)

this.options._const.oldValue,
t1.attributes[attr]
t1.attributes[attr],
)
.setValue(
this.options._const.newValue,
t2.attributes[attr]
)
t2.attributes[attr],
),
)

@@ -326,7 +330,7 @@ }

this.options._const.action,
this.options._const.addAttribute
this.options._const.addAttribute,
)
.setValue(this.options._const.route, route)
.setValue(this.options._const.name, attr)
.setValue(this.options._const.value, t2.attributes[attr])
.setValue(this.options._const.value, t2.attributes[attr]),
)

@@ -341,3 +345,3 @@ }

t2: elementDiffNodeType,
route: number[]
route: number[],
) {

@@ -348,3 +352,3 @@ const t1ChildNodes = t1.childNodes ? t1.childNodes.slice() : []

let childNodesLengthDifference = Math.abs(
t1ChildNodes.length - t2ChildNodes.length
t1ChildNodes.length - t2ChildNodes.length,
)

@@ -358,4 +362,4 @@ let diffs: Diff[] = []

: t1.childNodes && t2.childNodes
? markSubTrees(t1, t2)
: []
? markSubTrees(t1, t2)
: []
if (subtrees.length > 0) {

@@ -370,3 +374,3 @@ /* One or more groups have been identified among the childnodes of t1

route,
cachedSubtrees
cachedSubtrees,
)

@@ -399,12 +403,12 @@ if (diffs.length > 0) {

this.options._const.action,
this.options._const.removeTextElement
this.options._const.removeTextElement,
)
.setValue(
this.options._const.route,
route.concat(index)
route.concat(index),
)
.setValue(
this.options._const.value,
(e1 as textDiffNodeType).data
)
(e1 as textDiffNodeType).data,
),
)

@@ -417,12 +421,12 @@ index -= 1

this.options._const.action,
this.options._const.removeElement
this.options._const.removeElement,
)
.setValue(
this.options._const.route,
route.concat(index)
route.concat(index),
)
.setValue(
this.options._const.element,
cleanNode(e1)
)
cleanNode(e1),
),
)

@@ -437,12 +441,12 @@ index -= 1

this.options._const.action,
this.options._const.addTextElement
this.options._const.addTextElement,
)
.setValue(
this.options._const.route,
route.concat(index)
route.concat(index),
)
.setValue(
this.options._const.value,
(e2 as textDiffNodeType).data
)
(e2 as textDiffNodeType).data,
),
)

@@ -454,12 +458,12 @@ } else {

this.options._const.action,
this.options._const.addElement
this.options._const.addElement,
)
.setValue(
this.options._const.route,
route.concat(index)
route.concat(index),
)
.setValue(
this.options._const.element,
cleanNode(e2)
)
cleanNode(e2),
),
)

@@ -483,3 +487,3 @@ }

diffs = diffs.concat(
this.findNextDiff(e1, e2, route.concat(index))
this.findNextDiff(e1, e2, route.concat(index)),
)

@@ -493,12 +497,12 @@ } else if (!isEqual(e1, e2)) {

this.options._const.action,
this.options._const.removeTextElement
this.options._const.removeTextElement,
)
.setValue(
this.options._const.route,
route.concat(index)
route.concat(index),
)
.setValue(
this.options._const.value,
(e1 as textDiffNodeType).data
)
(e1 as textDiffNodeType).data,
),
)

@@ -510,12 +514,12 @@ } else {

this.options._const.action,
this.options._const.removeElement
this.options._const.removeElement,
)
.setValue(
this.options._const.element,
cleanNode(e1)
cleanNode(e1),
)
.setValue(
this.options._const.route,
route.concat(index)
)
route.concat(index),
),
)

@@ -533,11 +537,11 @@ }

this.options._const.action,
this.options._const.addElement
this.options._const.addElement,
)
.setValue(
this.options._const.element,
cleanNode(e2)
cleanNode(e2),
)
.setValue(
this.options._const.route,
route.concat(index)
route.concat(index),
),

@@ -552,15 +556,15 @@ ])

this.options._const.action,
this.options._const.replaceElement
this.options._const.replaceElement,
)
.setValue(
this.options._const.oldValue,
cleanNode(e1)
cleanNode(e1),
)
.setValue(
this.options._const.newValue,
cleanNode(e2)
cleanNode(e2),
)
.setValue(
this.options._const.route,
route.concat(index)
route.concat(index),
),

@@ -582,3 +586,3 @@ ])

route: number[],
cachedSubtrees: boolean
cachedSubtrees: boolean,
) {

@@ -645,11 +649,11 @@ /* Either t1.childNodes and t2.childNodes have the same length, or

this.options._const
.modifyTextElement
.modifyTextElement,
)
.setValue(
this.options._const.route,
route.concat(index1)
route.concat(index1),
)
.setValue(
this.options._const.oldValue,
node.data
node.data,
)

@@ -662,4 +666,4 @@ .setValue(

] as textDiffNodeType
).data
)
).data,
),
// t1ChildNodes at position index1 is not up-to-date, but that does not matter as

@@ -675,9 +679,9 @@ // index1 will increase +1

this.options._const.action,
this.options._const.removeTextElement
this.options._const.removeTextElement,
)
.setValue(
this.options._const.route,
route.concat(index1)
route.concat(index1),
)
.setValue(this.options._const.value, node.data)
.setValue(this.options._const.value, node.data),
)

@@ -697,16 +701,16 @@ gaps1.splice(index1, 1)

this.options._const.action,
this.options._const.replaceElement
this.options._const.replaceElement,
)
.setValue(
this.options._const.oldValue,
cleanNode(node)
cleanNode(node),
)
.setValue(
this.options._const.newValue,
cleanNode(t2ChildNodes[index2])
cleanNode(t2ChildNodes[index2]),
)
.setValue(
this.options._const.route,
route.concat(index1)
)
route.concat(index1),
),
)

@@ -720,12 +724,12 @@ // t1ChildNodes at position index1 is not up-to-date, but that does not matter as

this.options._const.action,
this.options._const.removeElement
this.options._const.removeElement,
)
.setValue(
this.options._const.route,
route.concat(index1)
route.concat(index1),
)
.setValue(
this.options._const.element,
cleanNode(node)
)
cleanNode(node),
),
)

@@ -745,9 +749,9 @@ gaps1.splice(index1, 1)

this.options._const.action,
this.options._const.addTextElement
this.options._const.addTextElement,
)
.setValue(
this.options._const.route,
route.concat(index1)
route.concat(index1),
)
.setValue(this.options._const.value, node.data)
.setValue(this.options._const.value, node.data),
)

@@ -766,12 +770,12 @@ gaps1.splice(index1, 0, true)

this.options._const.action,
this.options._const.addElement
this.options._const.addElement,
)
.setValue(
this.options._const.route,
route.concat(index1)
route.concat(index1),
)
.setValue(
this.options._const.element,
cleanNode(node)
)
cleanNode(node),
),
)

@@ -791,3 +795,3 @@ gaps1.splice(index1, 0, true)

group.newValue,
t1ChildNodes.length - group.length
t1ChildNodes.length - group.length,
)

@@ -804,3 +808,3 @@ if (toGroup !== group.oldValue) {

false,
true
true,
)

@@ -816,11 +820,11 @@ ) {

this.options._const.action,
this.options._const.relocateGroup
this.options._const.relocateGroup,
)
.setValue(
this.options._const.groupLength,
group.length
group.length,
)
.setValue(
this.options._const.from,
group.oldValue
group.oldValue,
)

@@ -840,3 +844,3 @@ .setValue(this.options._const.to, toGroup)

t2: elementDiffNodeType,
route: number[]
route: number[],
) {

@@ -853,7 +857,7 @@ // Differences of value. Only useful if the value/selection/checked value

this.options._const.action,
this.options._const.modifySelected
this.options._const.modifySelected,
)
.setValue(this.options._const.oldValue, t1.selected)
.setValue(this.options._const.newValue, t2.selected)
.setValue(this.options._const.route, route)
.setValue(this.options._const.route, route),
)

@@ -871,7 +875,7 @@ }

this.options._const.action,
this.options._const.modifyValue
this.options._const.modifyValue,
)
.setValue(this.options._const.oldValue, t1.value || "")
.setValue(this.options._const.newValue, t2.value || "")
.setValue(this.options._const.route, route)
.setValue(this.options._const.route, route),
)

@@ -884,7 +888,7 @@ }

this.options._const.action,
this.options._const.modifyChecked
this.options._const.modifyChecked,
)
.setValue(this.options._const.oldValue, t1.checked)
.setValue(this.options._const.newValue, t2.checked)
.setValue(this.options._const.route, route)
.setValue(this.options._const.route, route),
)

@@ -891,0 +895,0 @@ }

import { DiffDOMOptionsPartial, elementNodeType, textNodeType } from "../types"
import { checkElementType } from "../helpers"
export function nodeToObj(
aNode: Element,
options: DiffDOMOptionsPartial = { valueDiffing: true }
options: DiffDOMOptionsPartial = { valueDiffing: true },
) {

@@ -10,4 +11,6 @@ const objNode: elementNodeType | textNodeType = {

}
if (aNode instanceof Text || aNode instanceof Comment) {
;(objNode as unknown as textNodeType).data = aNode.data
if (checkElementType(aNode, "Text", "Comment")) {
;(objNode as unknown as textNodeType).data = (
aNode as unknown as Text | Comment
).data
} else {

@@ -19,3 +22,3 @@ if (aNode.attributes && aNode.attributes.length > 0) {

(attribute) =>
(objNode.attributes[attribute.name] = attribute.value)
(objNode.attributes[attribute.name] = attribute.value),
)

@@ -27,29 +30,44 @@ }

nodeArray.forEach((childNode) =>
objNode.childNodes.push(nodeToObj(childNode, options))
objNode.childNodes.push(nodeToObj(childNode, options)),
)
}
if (options.valueDiffing) {
if (aNode instanceof HTMLTextAreaElement) {
objNode.value = aNode.value
if (checkElementType(aNode, "HTMLTextAreaElement")) {
objNode.value = (aNode as HTMLTextAreaElement).value
}
if (
aNode instanceof HTMLInputElement &&
["radio", "checkbox"].includes(aNode.type.toLowerCase()) &&
aNode.checked !== undefined
checkElementType(aNode, "HTMLInputElement") &&
["radio", "checkbox"].includes(
(aNode as HTMLInputElement).type.toLowerCase(),
) &&
(aNode as HTMLInputElement).checked !== undefined
) {
objNode.checked = aNode.checked
objNode.checked = (aNode as HTMLInputElement).checked
} else if (
aNode instanceof HTMLButtonElement ||
aNode instanceof HTMLDataElement ||
aNode instanceof HTMLInputElement ||
aNode instanceof HTMLLIElement ||
aNode instanceof HTMLMeterElement ||
aNode instanceof HTMLOptionElement ||
aNode instanceof HTMLProgressElement ||
aNode instanceof HTMLParamElement
checkElementType(
aNode,
"HTMLButtonElement",
"HTMLDataElement",
"HTMLInputElement",
"HTMLLIElement",
"HTMLMeterElement",
"HTMLOptionElement",
"HTMLProgressElement",
"HTMLParamElement",
)
) {
objNode.value = aNode.value
objNode.value = (
aNode as
| HTMLButtonElement
| HTMLDataElement
| HTMLInputElement
| HTMLLIElement
| HTMLMeterElement
| HTMLOptionElement
| HTMLProgressElement
| HTMLParamElement
).value
}
if (aNode instanceof HTMLOptionElement) {
objNode.selected = aNode.selected
if (checkElementType(aNode, "HTMLOptionElement")) {
objNode.selected = (aNode as HTMLOptionElement).selected
}

@@ -56,0 +74,0 @@ }

@@ -106,3 +106,3 @@ import { DiffDOMOptionsPartial, nodeType } from "../types"

caseSensitive: false,
}
},
) => {

@@ -172,3 +172,3 @@ const result: nodeType[] = []

const data = unescape(
html.slice(start, html.indexOf("<", start))
html.slice(start, html.indexOf("<", start)),
)

@@ -230,3 +230,3 @@ current.node.childNodes.push({

let data = unescape(
html.slice(start, end === -1 ? undefined : end)
html.slice(start, end === -1 ? undefined : end),
)

@@ -233,0 +233,0 @@ childNodes.push({

@@ -21,4 +21,4 @@ import {

/ /g,
"."
)}`
".",
)}`,
)

@@ -105,3 +105,3 @@ }

elementNode.childNodes = diffNode.childNodes.map((diffChildNode) =>
cleanNode(diffChildNode)
cleanNode(diffChildNode),
)

@@ -121,3 +121,3 @@ }

return true
}
},
)

@@ -167,3 +167,3 @@ ) {

!e1.childNodes.every((childNode: nodeType, index: number) =>
isEqual(childNode, e2.childNodes[index])
isEqual(childNode, e2.childNodes[index]),
)

@@ -183,3 +183,3 @@ ) {

sameSiblings: boolean,
preventRecursion = false
preventRecursion = false,
) => {

@@ -248,3 +248,3 @@ if (!e1 || !e2) {

(element: nodeType, index: number) =>
element.nodeName === nodeList2[index].nodeName
element.nodeName === nodeList2[index].nodeName,
)

@@ -261,4 +261,4 @@ } else {

true,
true
)
true,
),
)

@@ -275,3 +275,3 @@ }

marked1: boolean[],
marked2: boolean[]
marked2: boolean[],
) => {

@@ -325,3 +325,3 @@ let lcsSize = 0

uniqueDescriptors,
subsetsSame
subsetsSame,
)

@@ -379,3 +379,3 @@ ) {

t2: elementDiffNodeType,
stable: subsetType[]
stable: subsetType[],
) => {

@@ -420,3 +420,3 @@ const gaps1: (true | number)[] = t1.childNodes

oldTree: elementDiffNodeType,
newTree: elementDiffNodeType
newTree: elementDiffNodeType,
) => {

@@ -442,3 +442,3 @@ // note: the child lists are views, and so update as we update old/newTree

marked1,
marked2
marked2,
)

@@ -448,6 +448,6 @@ if (subset) {

const subsetArray = Array(...new Array(subset.length)).map(
returnIndex
returnIndex,
)
subsetArray.forEach((item) =>
markBoth(marked1, marked2, subset, item)
markBoth(marked1, marked2, subset, item),
)

@@ -477,3 +477,1 @@ } else {

}
//export const elementHasValue = (element: Element) : boolean => element instanceof HTMLButtonElement || element instanceof HTMLDataElement || element instanceof HTMLInputElement || element instanceof HTMLLIElement || element instanceof HTMLMeterElement || element instanceof HTMLOptionElement || element instanceof HTMLProgressElement || element instanceof HTMLParamElement

@@ -0,1 +1,3 @@

import { checkElementType } from "./diffDOM/helpers"
/**

@@ -66,3 +68,3 @@ * Use TraceLogger to figure out function calls inside

| false
| (string | HTMLElement | number | boolean | false)[]
| (string | HTMLElement | number | boolean | false)[],
) {

@@ -81,3 +83,3 @@ this.padding += this.pad

| false
| (string | HTMLElement | number | boolean | false)[]
| (string | HTMLElement | number | boolean | false)[],
) {

@@ -87,3 +89,3 @@ this.log("│<──┘ generated return value", result)

0,
this.padding.length - this.pad.length
this.padding.length - this.pad.length,
)

@@ -111,3 +113,3 @@ }

| false
| (string | HTMLElement | number | boolean | false)[]
| (string | HTMLElement | number | boolean | false)[],
) {

@@ -120,4 +122,4 @@ if (!v) {

}
if (v instanceof HTMLElement) {
return v.outerHTML || "<empty>"
if (checkElementType(v, "HTMLElement")) {
return (v as HTMLElement).outerHTML || "<empty>"
}

@@ -124,0 +126,0 @@ if (v instanceof Array) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc