{"version":3,"file":"kendo.dom.min.js","names":["factory","define","amd","kendo","Node","this","node","NullNode","prototype","remove","parentNode","removeChild","attr","text","nodeName","style","children","NULL_NODE","Element","TextNode","nodeValue","String","HtmlNode","html","appendTo","parent","document","createElement","index","length","render","appendChild","cached","cachedChildren","cachedLength","Math","abs","replaceChild","syncAttributes","removeAttributes","cachedAttr","name","value","cachedValue","setStyle","setAttribute","key","removeStyle","cachedStyle","undefined","removeAttribute","cssText","className","str","i","createTextNode","nodes","el","lastChild","HTML_CONTAINER","innerHTML","firstChild","insertHtml","child","nextSibling","push","slice","element","attrs","Tree","root","dom","window"],"sources":["kendo.dom.js"],"mappings":"CAAA,SAAWA,GACW,mBAAXC,QAAyBA,OAAOC,IAAMD,OAAO,CAAC,kBAAmBD,GACxEA,IAFJ,EAGG,YASC,SAAUG,GACN,SAASC,IACLC,KAAKC,KAAO,KAgBhB,SAASC,KAbTH,EAAKI,UAAY,CACbC,OAAQ,WACAJ,KAAKC,KAAKI,YACVL,KAAKC,KAAKI,WAAWC,YAAYN,KAAKC,MAE1CD,KAAKO,KAAO,IAEhBA,KAAM,GACNC,KAAM,WACF,MAAO,KAOfN,EAASC,UAAY,CACjBM,SAAU,QACVF,KAAM,CAAEG,MAAO,IACfC,SAAU,GACVP,OAAQ,cAIZ,IAAIQ,EAAY,IAAIV,EAEpB,SAASW,EAAQJ,EAAUF,EAAMI,GAC7BX,KAAKS,SAAWA,EAEhBT,KAAKO,KAAOA,GAAQ,GAEpBP,KAAKW,SAAWA,GAAY,GAuJhC,SAASG,EAASC,GACdf,KAAKe,UAAYC,OAAOD,GAoC5B,SAASE,EAASC,GACdlB,KAAKkB,KAAOA,EA1LhBL,EAAQV,UAAY,IAAIJ,EAExBc,EAAQV,UAAUgB,SAAW,SAASC,GAKlC,IAJA,IAAInB,EAAOoB,SAASC,cAActB,KAAKS,UAEnCE,EAAWX,KAAKW,SAEXY,EAAQ,EAAGA,EAAQZ,EAASa,OAAQD,IACzCZ,EAASY,GA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EOA,EAAO1B,MAAS0B,EAAO1B,KAAKI,aACpCsB,EAAOvB,SACPuB,EAASf,GAHTe,EAASf,EAKbD,EAASY,GAAOE,OAAOzB,KAAKiE,KAAMtC,GAGtC,IAAKJ,EAAQC,EAAQD,EAAQK,EAAeJ,OAAQD,IAChDK,EAAeL,GAAOnB,SAG1BJ,KAAKW,SAAWA,IAIxBb,EAAMoE,IAAM,CACRhD,KAAMA,EACNV,KAAMA,EACNsD,QAASA,EACTE,KAAMA,EACNjE,KAAMA,GAhUd,CAkUGoE,OAAOrE","sourcesContent":["(function (factory) {\n typeof define === 'function' && define.amd ? define(['kendo.core'], factory) :\n factory();\n})((function () {\n var __meta__ = {\n id: \"dom\",\n name: \"Virtual DOM\",\n category: \"framework\",\n depends: [ \"core\" ],\n advanced: true\n };\n\n (function(kendo) {\n function Node() {\n this.node = null;\n }\n\n Node.prototype = {\n remove: function() {\n if (this.node.parentNode) {\n this.node.parentNode.removeChild(this.node);\n }\n this.attr = {};\n },\n attr: {},\n text: function() {\n return \"\";\n }\n };\n\n function NullNode() {\n }\n\n NullNode.prototype = {\n nodeName: \"#null\",\n attr: { style: {} },\n children: [],\n remove: function() {\n }\n };\n\n var NULL_NODE = new NullNode();\n\n function Element(nodeName, attr, children) {\n this.nodeName = nodeName;\n\n this.attr = attr || {};\n\n this.children = children || [];\n }\n\n Element.prototype = new Node();\n\n Element.prototype.appendTo = function(parent) {\n var node = document.createElement(this.nodeName);\n\n var children = this.children;\n\n for (var index = 0; index < children.length; index++) {\n children[index].render(node, NULL_NODE);\n }\n\n parent.appendChild(node);\n\n return node;\n };\n\n Element.prototype.render = function(parent, cached) {\n var node;\n\n if (cached.nodeName !== this.nodeName) {\n cached.remove();\n\n node = this.appendTo(parent);\n } else {\n node = cached.node;\n\n var index;\n\n var children = this.children;\n\n var length = children.length;\n\n var cachedChildren = cached.children;\n\n var cachedLength = cachedChildren.length;\n\n if (Math.abs(cachedLength - length) > 2) {\n this.render({\n appendChild: function(node) {\n parent.replaceChild(node, cached.node);\n }\n }, NULL_NODE);\n\n return;\n }\n\n for (index = 0; index < length; index++) {\n children[index].render(node, cachedChildren[index] || NULL_NODE);\n }\n\n for (index = length; index < cachedLength; index++) {\n cachedChildren[index].remove();\n }\n }\n\n this.node = node;\n\n this.syncAttributes(cached.attr);\n\n this.removeAttributes(cached.attr);\n };\n\n Element.prototype.syncAttributes = function(cachedAttr) {\n var attr = this.attr;\n\n for (var name in attr) {\n var value = attr[name];\n\n var cachedValue = cachedAttr[name];\n\n if (name === \"style\") {\n this.setStyle(value, cachedValue);\n } else if (value !== cachedValue) {\n this.setAttribute(name, value, cachedValue);\n }\n }\n };\n\n Element.prototype.setStyle = function(style, cachedValue) {\n var node = this.node;\n var key;\n\n if (cachedValue) {\n for (key in style) {\n if (style[key] !== cachedValue[key]) {\n node.style[key] = style[key];\n }\n }\n } else {\n for (key in style) {\n node.style[key] = style[key];\n }\n }\n };\n\n Element.prototype.removeStyle = function(cachedStyle) {\n var style = this.attr.style || {};\n var node = this.node;\n\n for (var key in cachedStyle) {\n if (style[key] === undefined) {\n node.style[key] = \"\";\n }\n }\n };\n\n Element.prototype.removeAttributes = function(cachedAttr) {\n var attr = this.attr;\n\n for (var name in cachedAttr) {\n if (name === \"style\") {\n this.removeStyle(cachedAttr.style);\n } else if (attr[name] === undefined) {\n this.removeAttribute(name);\n }\n }\n };\n\n Element.prototype.removeAttribute = function(name) {\n var node = this.node;\n\n if (name === \"style\") {\n node.style.cssText = \"\";\n } else if (name === \"className\") {\n node.className = \"\";\n } else {\n node.removeAttribute(name);\n }\n };\n\n Element.prototype.setAttribute = function(name, value) {\n var node = this.node;\n\n if (node[name] !== undefined) {\n node[name] = value;\n } else {\n node.setAttribute(name, value);\n }\n };\n\n Element.prototype.text = function() {\n var str = \"\";\n for (var i = 0; i < this.children.length; ++i) {\n str += this.children[i].text();\n }\n return str;\n };\n\n function TextNode(nodeValue) {\n this.nodeValue = String(nodeValue);\n }\n\n TextNode.prototype = new Node();\n\n TextNode.prototype.nodeName = \"#text\";\n\n TextNode.prototype.render = function(parent, cached) {\n var node;\n\n if (cached.nodeName !== this.nodeName) {\n cached.remove();\n\n node = document.createTextNode(this.nodeValue);\n\n parent.appendChild(node);\n } else {\n node = cached.node;\n\n if (this.nodeValue !== cached.nodeValue) {\n if (node.parentNode) {\n // sometimes in IE parentNode is null (reason unknown),\n // and IE throws an error when you try to set a\n // parentless' nodeValue, because why not.\n node.nodeValue = this.nodeValue;\n }\n }\n }\n\n this.node = node;\n };\n\n TextNode.prototype.text = function() {\n return this.nodeValue;\n };\n\n function HtmlNode(html) {\n this.html = html;\n }\n\n HtmlNode.prototype = {\n nodeName: \"#html\",\n attr: {},\n remove: function() {\n for (var index = 0; index < this.nodes.length; index++) {\n var el = this.nodes[index];\n if (el.parentNode) {\n el.parentNode.removeChild(el);\n }\n }\n },\n render: function(parent, cached) {\n if (cached.nodeName !== this.nodeName || cached.html !== this.html) {\n cached.remove();\n\n var lastChild = parent.lastChild;\n\n insertHtml(parent, this.html);\n\n this.nodes = [];\n\n for (var child = lastChild ? lastChild.nextSibling : parent.firstChild; child; child = child.nextSibling) {\n this.nodes.push(child);\n }\n } else {\n this.nodes = cached.nodes.slice(0);\n }\n }\n };\n\n var HTML_CONTAINER = document.createElement(\"div\");\n\n function insertHtml(node, html) {\n HTML_CONTAINER.innerHTML = html;\n\n while (HTML_CONTAINER.firstChild) {\n node.appendChild(HTML_CONTAINER.firstChild);\n }\n }\n\n function html(value) {\n return new HtmlNode(value);\n }\n\n function element(nodeName, attrs, children) {\n return new Element(nodeName, attrs, children);\n }\n\n function text(value) {\n return new TextNode(value);\n }\n\n function Tree(root) {\n this.root = root;\n this.children = [];\n }\n\n Tree.prototype = {\n html: html,\n element: element,\n text: text,\n render: function(children) {\n var cachedChildren = this.children;\n\n var index;\n\n var length;\n\n for (index = 0, length = children.length; index < length; index++) {\n var cached = cachedChildren[index];\n if (!cached) {\n cached = NULL_NODE;\n } else if (!cached.node || !cached.node.parentNode) {\n cached.remove();\n cached = NULL_NODE;\n }\n children[index].render(this.root, cached);\n }\n\n for (index = length; index < cachedChildren.length; index++) {\n cachedChildren[index].remove();\n }\n\n this.children = children;\n }\n };\n\n kendo.dom = {\n html: html,\n text: text,\n element: element,\n Tree: Tree,\n Node: Node\n };\n })(window.kendo);\n\n}));\n"]}