UNPKG

sinuous

Version:

🧬 Small, fast, reactive render engine

2 lines (1 loc) • 2.59 kB
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("sinuous/observable"),require("sinuous/htm")):"function"==typeof define&&define.amd?define(["exports","sinuous/observable","sinuous/htm"],n):n((e=e||self).sinuous={},e.observable,e.htm)}(this,function(e,n,t){var i={},f=[],o="__g";function r(e,n,t,i){if(t){if(n){if(!i){var f=(i=t.previousSibling||e.lastChild)[o];if(f)for(i=i.previousSibling;i&&i[o]!==f;)i=i.previousSibling}for(var r;i&&i!==t;)r=i.nextSibling,e.removeChild(i),i[o]=0,i=r}}else e.textContent=""}var u=0;function s(e,n,t,c){e=t&&t.parentNode||e;var l=typeof n;return n===c||(!n&&0!==n||!0===n?(r(e,c,t),c=null):c&&"string"!=typeof c||!("string"===l||"number"===l&&(n+=""))?"function"===l?i.subscribe(function(){c=s(e,n(),t,c)}):(r(e,c,t),n instanceof Node||(n=i.h(f,n)),11===n.nodeType&&n.firstChild!==n.lastChild&&(n.firstChild[o]=n.lastChild[o]=++u),e.insertBefore(n,t||null),c=n):(null!=c&&e.firstChild?t?(t.previousSibling||e.lastChild).data=n:e.firstChild.data=n:t?e.insertBefore(document.createTextNode(n),t):e.textContent=n,c=n)),c}function c(e,n){for(var t in e)i[t]=e[t];function o(){var e,t=f.slice.call(arguments);function i(f){var o=typeof f;if(null==f);else if("string"===o)e?e.appendChild(document.createTextNode(f)):e=n?document.createElementNS("http://www.w3.org/2000/svg",f):document.createElement(f);else if(Array.isArray(f))e||(e=document.createDocumentFragment()),f.forEach(i);else if(f instanceof Node)e?e.appendChild(f):e=f;else if("object"===o)for(var r in f)l(r,f[r],e,n);else if("function"===o)if(e){var u=e.appendChild(document.createTextNode(""));f.$t?f.$t(1,s,e,""):s(e,f,u)}else e=f.apply(null,t.splice(0));else e.appendChild(document.createTextNode(""+f))}for(;t.length;)i(t.shift());return e}return i.h=o,o}function l(e,n,t,f,o){if("o"!==e[0]||"n"!==e[1]||n.$o)if("function"==typeof n)n.$t?n.$t(2,l,t,e):i.subscribe(function(){l(e,n(),t,f,o)});else if(o)t.style.setProperty(e,n);else if(f||"data-"===e.slice(0,5)||"aria-"===e.slice(0,5))t.setAttribute(e,n);else if("style"===e)if("string"==typeof n)t.style.cssText=n;else for(e in n)l(e,n[e],t,f,!0);else if("attrs"===e)for(e in n)l(e,n[e],t,!0);else"class"===e&&(e+="Name"),t[e]=n;else!function(e,n,t){n=n.slice(2);var f=i.cleanup(function(){return e.removeEventListener(n,a)});t?e.addEventListener(n,a):f(),(e.t||(e.t={}))[n]=t}(t,e,n)}function a(e){return this.t[e.type](e)}var d=c(n),v=c(n,!0),m=n.o;e.api=i,e.context=c,e.h=d,e.hs=v,e.html=function(){return t.apply(d,arguments)},e.o=m,e.observable=m,e.svg=function(){return t.apply(v,arguments)}});