@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
3 lines (2 loc) • 4.02 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("kendo.core.js")):"function"==typeof define&&define.amd?define(["exports","kendo.core.min"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).kendo=e.kendo||{},e.kendo._globals=e.kendo._globals||{},e.kendo._globals.Dom={}))}(this,(function(e){!function(e){function t(){this.node=null}function n(){}t.prototype={remove:function(){this.node.parentNode&&this.node.parentNode.removeChild(this.node),this.attr={}},attr:{},text:function(){return""}},n.prototype={nodeName:"#null",attr:{style:{}},children:[],remove:function(){}};var o=new n;function r(e,t,n){this.nodeName=e,this.attr=t||{},this.children=n||[]}function i(e,t){this.nodeValue=String(e),this.force=t}function d(e,t){this.html=e,this.replace=t}r.prototype=new t,r.prototype.appendTo=function(e){for(var t="string"==typeof this.nodeName?document.createElement(this.nodeName):this.nodeName,n=this.children,r=0;r<n.length;r++)n[r].render(t,o);return e.appendChild(t),t},r.prototype.render=function(e,t){var n;if(t.nodeName!==this.nodeName)t.remove(),n=this.appendTo(e);else{var r;n=t.node;var i=this.children,d=i.length,s=t.children,h=s.length;if(Math.abs(h-d)>2)return void this.render({appendChild:function(n){e.replaceChild(n,t.node)}},o);for(r=0;r<d;r++)i[r].render(n,s[r]||o);for(r=d;r<h;r++)s[r].remove()}this.node=n,this.syncAttributes(t.attr),this.removeAttributes(t.attr)},r.prototype.syncAttributes=function(e){var t=this.attr;for(var n in t){var o=t[n],r=e[n];"style"===n?this.setStyle(o,r):o!==r&&this.setAttribute(n,o,r)}},r.prototype.setStyle=function(e,t){var n,o=this.node;if(t)for(n in e)e[n]!==t[n]&&(o.style[n]=e[n]);else for(n in e)o.style[n]=e[n]},r.prototype.removeStyle=function(e){var t=this.attr.style||{},n=this.node;for(var o in e)void 0===t[o]&&(n.style[o]="")},r.prototype.removeAttributes=function(e){var t=this.attr;for(var n in e)"style"===n?this.removeStyle(e.style):void 0===t[n]&&this.removeAttribute(n)},r.prototype.removeAttribute=function(e){var t=this.node;"style"===e?t.style.cssText="":"className"===e?t.className="":t.removeAttribute(e)},r.prototype.setAttribute=function(e,t){var n=this.node;void 0!==n[e]?n[e]=t:n.setAttribute(e,t)},r.prototype.text=function(){for(var e="",t=0;t<this.children.length;++t)e+=this.children[t].text();return e},i.prototype=new t,i.prototype.nodeName="#text",i.prototype.render=function(e,t){var n;t.nodeName!==this.nodeName||this.force?(t.remove(),n=document.createTextNode(this.nodeValue),e.appendChild(n)):(n=t.node,this.nodeValue!==t.nodeValue&&n.parentNode&&(n.nodeValue=this.nodeValue)),this.node=n},i.prototype.text=function(){return this.nodeValue},d.prototype={nodeName:"#html",attr:{},remove:function(){for(var e=0;e<this.nodes.length;e++){var t=this.nodes[e];t.parentNode&&t.parentNode.removeChild(t)}},render:function(e,t){var n,o;if(t.nodeName!==this.nodeName||t.html!==this.html||this.replace){this.replace&&t.replace&&t.nodes&&t.nodes.length&&t.nodes[0].outerHTML?(o=function(e,t,n){var o;return s.innerHTML=n,o=s.firstChild,e.replaceChild(o,t),o}(e,t.nodes[0],this.html),n=e.lastChild):(t.remove(),n=e.lastChild,function(e,t){s.innerHTML=t;for(;s.firstChild;)e.appendChild(s.firstChild)}(e,this.html)),this.nodes=[],o&&this.nodes.push(o);for(var r=n?n.nextSibling:e.firstChild;r;r=r.nextSibling)this.nodes.push(r)}else this.nodes=t.nodes.slice(0)}};var s=document.createElement("div");function h(e,t){return new d(e,t)}function l(e,t,n){return new r(e,t,n)}function a(e,t){return new i(e,t)}function u(e){this.root=e,this.children=[]}u.prototype={html:h,element:l,text:a,render:function(e){var t,n,r=this.children;for(t=0,n=e.length;t<n;t++){var i=r[t];i?i.node&&i.node.parentNode||(i.remove(),i=o):i=o,e[t].render(this.root,i)}for(t=n;t<r.length;t++)r[t].remove();this.children=e}},e.dom={html:h,text:a,element:l,Tree:u,Node:t}}(window.kendo),e.__meta__={id:"dom",name:"Virtual DOM",category:"framework",depends:["core"],advanced:!0}}));
//# sourceMappingURL=kendo.dom.min.js.map