pop
Version:
Pop is a [Hyperapp](https://github.com/hyperapp/hyperapp) / [Ultradom](https://github.com/ultradom/ultradom) spin-off project — yet another micro-framework for creating graphical user interfaces. This is not the final title, but let's go with that for now
2 lines • 2.75 kB
JavaScript
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e.picodom={})}(this,function(e){"use strict";function n(e,n){for(var t,r=[],o=[],i=arguments.length;i-- >2;)r.push(arguments[i]);for(;r.length;)if((t=r.pop())&&t.pop)for(i=t.length;i--;)r.push(t[i]);else null!=t&&!0!==t&&!1!==t&&o.push(t);return"function"==typeof e?e(n||{},o):{nodeName:e,attributes:n||{},children:o,key:n&&n.key}}function t(e,n){for(n=c(n&&n.parentNode,n,(s=n&&null!=n.node)?n.node:n&&r(n),e),n.node=e;p.length;)p.pop()();return n}function r(e){return{nodeName:e.nodeName.toLowerCase(),attributes:{},children:h.call(e.childNodes,function(e){return 3===e.nodeType?e.nodeValue:r(e)})}}function o(e,n){var t={};for(var r in e)t[r]=e[r];for(var r in n)t[r]=n[r];return t}function i(e){return e?e.key:null}function l(e,n,t,r,i){if("key"===n);else if("style"===n)for(var l in o(i,t))e[n][l]=null==t||null==t[l]?"":t[l];else"function"==typeof t||n in e&&!r?e[n]=null==t?"":t:null!=t&&!1!==t&&e.setAttribute(n,t),null!=t&&!1!==t||e.removeAttribute(n)}function u(e,n){var t="string"==typeof e||"number"==typeof e?document.createTextNode(e):(n=n||"svg"===e.nodeName)?document.createElementNS("http://www.w3.org/2000/svg",e.nodeName):document.createElement(e.nodeName),r=e.attributes;if(r){r.oncreate&&p.push(function(){r.oncreate(t)});for(var o=0;o<e.children.length;o++)t.appendChild(u(e.children[o],n));for(var i in r)l(t,i,r[i],n)}return t}function f(e,n,t,r){for(var i in o(n,t))t[i]!==("value"===i||"checked"===i?e[i]:n[i])&&l(e,i,t[i],r,n[i]);var u=s?t.onupdate:t.oncreate;u&&p.push(function(){u(e,n)})}function a(e,n){var t=n.attributes;if(t){for(var r=0;r<n.children.length;r++)a(e.childNodes[r],n.children[r]);t.ondestroy&&t.ondestroy(e)}return e}function d(e,n,t){function r(){e.removeChild(a(n,t))}var o=t.attributes&&t.attributes.onremove;o?o(n,r):r()}function c(e,n,t,r,o){if(r===t);else if(null==t||t.nodeName!==r.nodeName){var l=u(r,o);e&&(e.insertBefore(l,n),d(e,n,t)),n=l}else if(null==t.nodeName)n.nodeValue=r;else{f(n,t.attributes,r.attributes,o=o||"svg"===r.nodeName);for(var a=[],s={},h={},p=0;p<t.children.length;p++){a[p]=n.childNodes[p];var v=t.children[p],m=i(v);null!=m&&(s[m]=[a[p],v])}for(var p=0,y=0;y<r.children.length;){var v=t.children[p],N=r.children[y],m=i(v),g=i(N);if(h[m])p++;else if(null==g)null==m&&(c(n,a[p],v,N,o),y++),p++;else{var b=s[g]||[];m===g?(c(n,b[0],b[1],N,o),p++):b[0]?c(n,n.insertBefore(b[0],a[p]),b[1],N,o):c(n,a[p],null,N,o),y++,h[g]=N}}for(;p<t.children.length;){var v=t.children[p];null==i(v)&&d(n,a[p],v),p++}for(var p in s)h[s[p][1].key]||d(n,s[p][0],s[p][1])}return n}var s,h=[].map,p=[];e.h=n,e.patch=t});
//# sourceMappingURL=picodom.js.map