-
-
Notifications
You must be signed in to change notification settings - Fork 193
Expand file tree
/
Copy pathpreact.js
More file actions
1 lines (1 loc) · 8.52 KB
/
preact.js
File metadata and controls
1 lines (1 loc) · 8.52 KB
1
define(function(){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,n){!function(){"use strict";function t(){}function n(e,n){var o,r,i,l,u=E;for(l=arguments.length;l-- >2;)W.push(arguments[l]);for(n&&null!=n.children&&(W.length||W.push(n.children),delete n.children);W.length;)if((r=W.pop())&&void 0!==r.pop)for(l=r.length;l--;)W.push(r[l]);else"boolean"==typeof r&&(r=null),(i="function"!=typeof e)&&(null==r?r="":"number"==typeof r?r+="":"string"!=typeof r&&(i=!1)),i&&o?u[u.length-1]+=r:u===E?u=[r]:u.push(r),o=i;var a=new t;return a.nodeName=e,a.children=u,a.attributes=null==n?void 0:n,a.key=null==n?void 0:n.key,void 0!==P.vnode&&P.vnode(a),a}function o(e,t){for(var n in t)e[n]=t[n];return e}function r(e,t){return n(e.nodeName,o(o({},e.attributes),t),arguments.length>2?[].slice.call(arguments,2):e.children)}function i(e){!e.__d&&(e.__d=!0)&&1==j.push(e)&&(P.debounceRendering||V)(l)}function l(){var e,t=j;for(j=[];e=t.pop();)e.__d&&U(e)}function u(e,t,n){return"string"==typeof t||"number"==typeof t?void 0!==e.splitText:"string"==typeof t.nodeName?!e._componentConstructor&&a(e,t.nodeName):n||e._componentConstructor===t.nodeName}function a(e,t){return e.__n===t||e.nodeName.toLowerCase()===t.toLowerCase()}function c(e){var t=o({},e.attributes);t.children=e.children;var n=e.nodeName.defaultProps;if(void 0!==n)for(var r in n)void 0===t[r]&&(t[r]=n[r]);return t}function p(e,t){var n=t?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e);return n.__n=e,n}function _(e){var t=e.parentNode;t&&t.removeChild(e)}function s(e,t,n,o,r){if("className"===t&&(t="class"),"key"===t);else if("ref"===t)n&&n(null),o&&o(e);else if("class"!==t||r)if("style"===t){if(o&&"string"!=typeof o&&"string"!=typeof n||(e.style.cssText=o||""),o&&"object"==typeof o){if("string"!=typeof n)for(var i in n)i in o||(e.style[i]="");for(var i in o)e.style[i]="number"==typeof o[i]&&!1===A.test(i)?o[i]+"px":o[i]}}else if("dangerouslySetInnerHTML"===t)o&&(e.innerHTML=o.__html||"");else if("o"==t[0]&&"n"==t[1]){var l=t!==(t=t.replace(/Capture$/,""));t=t.toLowerCase().substring(2),o?n||e.addEventListener(t,d,l):e.removeEventListener(t,d,l),(e.__l||(e.__l={}))[t]=o}else if("list"!==t&&"type"!==t&&!r&&t in e)f(e,t,null==o?"":o),null!=o&&!1!==o||e.removeAttribute(t);else{var u=r&&t!==(t=t.replace(/^xlink\:?/,""));null==o||!1===o?u?e.removeAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase()):e.removeAttribute(t):"function"!=typeof o&&(u?e.setAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase(),o):e.setAttribute(t,o))}else e.className=o||""}function f(e,t,n){try{e[t]=n}catch(e){}}function d(e){return this.__l[e.type](P.event&&P.event(e)||e)}function v(){for(var e;e=D.pop();)P.afterMount&&P.afterMount(e),e.componentDidMount&&e.componentDidMount()}function h(e,t,n,o,r,i){H++||(O=null!=r&&void 0!==r.ownerSVGElement,R=null!=e&&!("__preactattr_"in e));var l=m(e,t,n,o,i);return r&&l.parentNode!==r&&r.appendChild(l),--H||(R=!1,i||v()),l}function m(e,t,n,o,r){var i=e,l=O;if(null!=t&&"boolean"!=typeof t||(t=""),"string"==typeof t||"number"==typeof t)return e&&void 0!==e.splitText&&e.parentNode&&(!e._component||r)?e.nodeValue!=t&&(e.nodeValue=t):(i=document.createTextNode(t),e&&(e.parentNode&&e.parentNode.replaceChild(i,e),y(e,!0))),i.__preactattr_=!0,i;var u=t.nodeName;if("function"==typeof u)return L(e,t,n,o);if(O="svg"===u||"foreignObject"!==u&&O,u+="",(!e||!a(e,u))&&(i=p(u,O),e)){for(;e.firstChild;)i.appendChild(e.firstChild);e.parentNode&&e.parentNode.replaceChild(i,e),y(e,!0)}var c=i.firstChild,_=i.__preactattr_,s=t.children;if(null==_){_=i.__preactattr_={};for(var f=i.attributes,d=f.length;d--;)_[f[d].name]=f[d].value}return!R&&s&&1===s.length&&"string"==typeof s[0]&&null!=c&&void 0!==c.splitText&&null==c.nextSibling?c.nodeValue!=s[0]&&(c.nodeValue=s[0]):(s&&s.length||null!=c)&&b(i,s,n,o,R||null!=_.dangerouslySetInnerHTML),x(i,t.attributes,_),O=l,i}function b(e,t,n,o,r){var i,l,a,c,p,s=e.childNodes,f=[],d={},v=0,h=0,b=s.length,g=0,x=t?t.length:0;if(0!==b)for(var C=0;C<b;C++){var N=s[C],w=N.__preactattr_,k=x&&w?N._component?N._component.__k:w.key:null;null!=k?(v++,d[k]=N):(w||(void 0!==N.splitText?!r||N.nodeValue.trim():r))&&(f[g++]=N)}if(0!==x)for(var C=0;C<x;C++){c=t[C],p=null;var k=c.key;if(null!=k)v&&void 0!==d[k]&&(p=d[k],d[k]=void 0,v--);else if(!p&&h<g)for(i=h;i<g;i++)if(void 0!==f[i]&&u(l=f[i],c,r)){p=l,f[i]=void 0,i===g-1&&g--,i===h&&h++;break}p=m(p,c,n,o),a=s[C],p&&p!==e&&p!==a&&(null==a?e.appendChild(p):p===a.nextSibling?_(a):e.insertBefore(p,a))}if(v)for(var C in d)void 0!==d[C]&&y(d[C],!1);for(;h<=g;)void 0!==(p=f[g--])&&y(p,!1)}function y(e,t){var n=e._component;n?M(n):(null!=e.__preactattr_&&e.__preactattr_.ref&&e.__preactattr_.ref(null),!1!==t&&null!=e.__preactattr_||_(e),g(e))}function g(e){for(e=e.lastChild;e;){var t=e.previousSibling;y(e,!0),e=t}}function x(e,t,n){var o;for(o in n)t&&null!=t[o]||null==n[o]||s(e,o,n[o],n[o]=void 0,O);for(o in t)"children"===o||"innerHTML"===o||o in n&&t[o]===("value"===o||"checked"===o?e[o]:n[o])||s(e,o,n[o],n[o]=t[o],O)}function C(e){var t=e.constructor.name;(I[t]||(I[t]=[])).push(e)}function N(e,t,n){var o,r=I[e.name];if(e.prototype&&e.prototype.render?(o=new e(t,n),T.call(o,t,n)):(o=new T(t,n),o.constructor=e,o.render=w),r)for(var i=r.length;i--;)if(r[i].constructor===e){o.__b=r[i].__b,r.splice(i,1);break}return o}function w(e,t,n){return this.constructor(e,n)}function k(e,t,n,o,r){e.__x||(e.__x=!0,(e.__r=t.ref)&&delete t.ref,(e.__k=t.key)&&delete t.key,!e.base||r?e.componentWillMount&&e.componentWillMount():e.componentWillReceiveProps&&e.componentWillReceiveProps(t,o),o&&o!==e.context&&(e.__c||(e.__c=e.context),e.context=o),e.__p||(e.__p=e.props),e.props=t,e.__x=!1,0!==n&&(1!==n&&!1===P.syncComponentUpdates&&e.base?i(e):U(e,1,r)),e.__r&&e.__r(e))}function U(e,t,n,r){if(!e.__x){var i,l,u,a=e.props,p=e.state,_=e.context,s=e.__p||a,f=e.__s||p,d=e.__c||_,m=e.base,b=e.__b,g=m||b,x=e._component,C=!1;if(m&&(e.props=s,e.state=f,e.context=d,2!==t&&e.shouldComponentUpdate&&!1===e.shouldComponentUpdate(a,p,_)?C=!0:e.componentWillUpdate&&e.componentWillUpdate(a,p,_),e.props=a,e.state=p,e.context=_),e.__p=e.__s=e.__c=e.__b=null,e.__d=!1,!C){i=e.render(a,p,_),e.getChildContext&&(_=o(o({},_),e.getChildContext()));var w,L,T=i&&i.nodeName;if("function"==typeof T){var S=c(i);l=x,l&&l.constructor===T&&S.key==l.__k?k(l,S,1,_,!1):(w=l,e._component=l=N(T,S,_),l.__b=l.__b||b,l.__u=e,k(l,S,0,_,!1),U(l,1,n,!0)),L=l.base}else u=g,w=x,w&&(u=e._component=null),(g||1===t)&&(u&&(u._component=null),L=h(u,i,_,n||!m,g&&g.parentNode,!0));if(g&&L!==g&&l!==x){var W=g.parentNode;W&&L!==W&&(W.replaceChild(L,g),w||(g._component=null,y(g,!1)))}if(w&&M(w),e.base=L,L&&!r){for(var E=e,V=e;V=V.__u;)(E=V).base=L;L._component=E,L._componentConstructor=E.constructor}}if(!m||n?D.unshift(e):C||(e.componentDidUpdate&&e.componentDidUpdate(s,f,d),P.afterUpdate&&P.afterUpdate(e)),null!=e.__h)for(;e.__h.length;)e.__h.pop().call(e);H||r||v()}}function L(e,t,n,o){for(var r=e&&e._component,i=r,l=e,u=r&&e._componentConstructor===t.nodeName,a=u,p=c(t);r&&!a&&(r=r.__u);)a=r.constructor===t.nodeName;return r&&a&&(!o||r._component)?(k(r,p,3,n,o),e=r.base):(i&&!u&&(M(i),e=l=null),r=N(t.nodeName,p,n),e&&!r.__b&&(r.__b=e,l=null),k(r,p,1,n,o),e=r.base,l&&e!==l&&(l._component=null,y(l,!1))),e}function M(e){P.beforeUnmount&&P.beforeUnmount(e);var t=e.base;e.__x=!0,e.componentWillUnmount&&e.componentWillUnmount(),e.base=null;var n=e._component;n?M(n):t&&(t.__preactattr_&&t.__preactattr_.ref&&t.__preactattr_.ref(null),e.__b=t,_(t),C(e),g(t)),e.__r&&e.__r(null)}function T(e,t){this.__d=!0,this.context=t,this.props=e,this.state=this.state||{}}function S(e,t,n){return h(n,e,{},!1,t,!1)}var P={},W=[],E=[],V="function"==typeof Promise?Promise.resolve().then.bind(Promise.resolve()):setTimeout,A=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,j=[],D=[],H=0,O=!1,R=!1,I={};o(T.prototype,{setState:function(e,t){var n=this.state;this.__s||(this.__s=o({},n)),o(n,"function"==typeof e?e(n,this.props):e),t&&(this.__h=this.__h||[]).push(t),i(this)},forceUpdate:function(e){e&&(this.__h=this.__h||[]).push(e),U(this,2)},render:function(){}});var $={h:n,createElement:n,cloneElement:r,Component:T,render:S,rerender:l,options:P};e.exports=$}()}])});