UNPKG

@progress/kendo-ui

Version:

This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.

3 lines 4.11 kB
/* @license */ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`kendo.core.min.js`)):typeof define==`function`&&define.amd?define([`exports`,`kendo.core.min`],t):(e=typeof globalThis<`u`?globalThis:e||self,t((e.kendo=e.kendo||{},e.kendo._globals=e.kendo._globals||{},e.kendo._globals.Dom={}),e.kendo._globals.Core))})(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`}),(function(e){function t(){this.node=null}t.prototype={remove:function(){this.node.parentNode&&this.node.parentNode.removeChild(this.node),this.attr={}},attr:{},text:function(){return``}};function n(){}n.prototype={nodeName:`#null`,attr:{style:{}},children:[],remove:function(){}};var r=new n;function i(e,t,n){this.nodeName=e,this.attr=t||{},this.children=n||[]}i.prototype=new t,i.prototype.appendTo=function(e){for(var t=typeof this.nodeName==`string`?document.createElement(this.nodeName):this.nodeName,n=this.children,i=0;i<n.length;i++)n[i].render(t,r);return e.appendChild(t),t},i.prototype.render=function(e,t){var n;if(t.nodeName!==this.nodeName)t.remove(),n=this.appendTo(e);else{n=t.node;var i,a=this.children,o=a.length,s=t.children,c=s.length;if(Math.abs(c-o)>2){this.render({appendChild:function(n){e.replaceChild(n,t.node)}},r);return}for(i=0;i<o;i++)a[i].render(n,s[i]||r);for(i=o;i<c;i++)s[i].remove()}this.node=n,this.syncAttributes(t.attr),this.removeAttributes(t.attr)},i.prototype.syncAttributes=function(e){var t=this.attr;for(var n in t){var r=t[n],i=e[n];n===`style`?this.setStyle(r,i):r!==i&&this.setAttribute(n,r,i)}},i.prototype.setStyle=function(e,t){var n=this.node,r;if(t)for(r in e)e[r]!==t[r]&&(n.style[r]=e[r]);else for(r in e)n.style[r]=e[r]},i.prototype.removeStyle=function(e){var t=this.attr.style||{},n=this.node;for(var r in e)t[r]===void 0&&(n.style[r]=``)},i.prototype.removeAttributes=function(e){var t=this.attr;for(var n in e)n===`style`?this.removeStyle(e.style):t[n]===void 0&&this.removeAttribute(n)},i.prototype.removeAttribute=function(e){var t=this.node;e===`style`?t.style.cssText=``:e===`className`?t.className=``:t.removeAttribute(e)},i.prototype.setAttribute=function(e,t){var n=this.node;n[e]===void 0?n.setAttribute(e,t):n[e]=t},i.prototype.text=function(){for(var e=``,t=0;t<this.children.length;++t)e+=this.children[t].text();return e};function a(e,t){this.nodeValue=String(e),this.force=t}a.prototype=new t,a.prototype.nodeName=`#text`,a.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},a.prototype.text=function(){return this.nodeValue};function o(e,t){this.html=e,this.replace=t}o.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,r;if(t.nodeName!==this.nodeName||t.html!==this.html||this.replace){this.replace&&t.replace&&t.nodes&&t.nodes.length&&t.nodes[0].outerHTML?(r=l(e,t.nodes[0],this.html),n=e.lastChild):(t.remove(),n=e.lastChild,c(e,this.html)),this.nodes=[],r&&this.nodes.push(r);for(var i=n?n.nextSibling:e.firstChild;i;i=i.nextSibling)this.nodes.push(i)}else this.nodes=t.nodes.slice(0)}};var s=document.createElement(`div`);function c(e,t){for(s.innerHTML=t;s.firstChild;)e.appendChild(s.firstChild)}function l(e,t,n){var r;return s.innerHTML=n,r=s.firstChild,e.replaceChild(r,t),r}function u(e,t){return new o(e,t)}function d(e,t,n){return new i(e,t,n)}function f(e,t){return new a(e,t)}function p(e){this.root=e,this.children=[]}p.prototype={html:u,element:d,text:f,render:function(e){var t=this.children,n,i;for(n=0,i=e.length;n<i;n++){var a=t[n];a?(!a.node||!a.node.parentNode)&&(a.remove(),a=r):a=r,e[n].render(this.root,a)}for(n=i;n<t.length;n++)t[n].remove();this.children=e}},e.dom={html:u,text:f,element:d,Tree:p,Node:t}})(window.kendo),e.__meta__={id:`dom`,name:`Virtual DOM`,category:`framework`,depends:[`core`],advanced:!0}}); //# sourceMappingURL=kendo.dom.min.js.map