Comparing version 7.0.1 to 7.0.2
@@ -1,2 +0,2 @@ | ||
var t,e,n,i={},r={},o="eid",f=[],u={},d=[],s=["abort","blur","error","focus","load","mouseenter","mouseleave","resize","scroll","unload"],a="string",c="number",h="boolean",v="undefined",p="object",y="function",l="events",m="style",b="value";function g(t){return Array.isArray(t)}function k(){return Math.random().toString(36).substring(2)+(new Date).getTime().toString(36)}function S(t,e){for(var n=0,i=e.length;n<i;n++)g(e[n])?S(t,e[n]):t.push(e[n]);return t}function N(t,e){for(var n in e)t[n]=e[n];return t}function A(t,e,n){return N(N(t,e),n)}function O(t,e){for(var n=[],i=arguments.length-2;i-- >0;)n[i]=arguments[i+2];return{e:t,a:N({},e),c:S([],n)}}function j(r,o,f){void 0===f&&(f={}),i=N({},f),e=r,t=document.getElementById(o),n=C(r()),B(t,n),_()}function x(t){void 0===t&&(t={});var e=t.name;void 0===e&&(e="");var n=t.state;void 0===n&&(n={});var o=t.mounted;void 0===o&&(o=function(){});var f=t.updated;void 0===f&&(f=function(){});var u=t.unmounted;void 0===u&&(u=function(){});var d=t.methods;void 0===d&&(d=function(){});var s=t.render;void 0===s&&(s=function(){});var a=k();return function(t){return void 0===t&&(t={}),{id:a,init:function(){return this.id=a,this.name=e+(t.key?"_"+t.key:""),this.key=this.id+(this.name||""),this.props=t,this.store=i,this.getStore=E,this.setStore=function(t,e){typeof t===y&&(t=t(i)),i=A({},i,t),z(),typeof e===y&&e.bind(this)()}.bind(this),this.getState=function(){return N({},r[this.key])}.bind(this),this.setState=function(t,e){typeof t===y&&(t=t(r[this.key])),r[this.key]=A({},r[this.key],t),z(),typeof e===y&&e.bind(this)()}.bind(this),this.createState=function(){typeof r[this.key]===v&&(r[this.key]=n)}.bind(this)(),this.deleteState=function(){delete r[this.key]}.bind(this),this.mounted=o.bind(this),this.updated=f.bind(this),this.unmounted=u.bind(this),function(t,e){for(var n in typeof e===y&&(e=e.bind(t)()),e)t[n]=e[n].bind(t)}(this,d),this.render=s.bind(this),this}}}}function E(){return N({},i)}function C(t){if(typeof t===v)return t;if(typeof t.e===y){var e=N({},t.a.props);delete t.a.props,t=t.e(e)}if(typeof t.init===y){var n=new t.init;typeof(t=n.render())===p&&(t.id=n.id,t.m=n.mounted,t.up=n.updated,t.un=n.unmounted,t.d=n.deleteState)}if(g(t.c))for(var i=0,r=t.c.length;i<r;i++)t.c[i]=C(t.c[i]);return t}function L(t){var e=typeof t;if(e===a||e===c)return document.createTextNode(t);if(e===h||e===v)return document.createTextNode("");var n=document.createElement(t.e);if(typeof t.a===p)for(var i=Object.keys(t.a),r=i.length;r--;)i[r]===l?(t.eid=k(),w(t.eid,t.a[i[r]],n)):i[r]===m?J(t.a[i[r]],n):n.setAttribute(i[r],t.a[i[r]]);if(q(t,"m"),g(t.c))for(var o=0,f=t.c.length;o<f;o++)B(n,t.c[o]);return n}function T(t){if("#document"!==t.parentNode.nodeName){var e=t.getAttribute("data-"+o);return typeof e===a?e:T(t.parentNode)}}function w(e,n,i){i.setAttribute("data-"+o,e),u[e]=n;for(var r=Object.keys(n),d=r.length;d--;)s.includes(r[d])?i.addEventListener(r[d],u[e][r[d]]):f.includes(r[d])||(f.push(r[d]),t.addEventListener(r[d],function(t){var e=T(t.target);if(typeof e===a&&u[e]){var n=u[e][t.type];typeof n===y&&n(t)}}))}function J(t,e){if(typeof t!==v)for(var n=Object.keys(t),i=n.length;i--;)e.style[n[i]]=t[n[i]]}function z(i){var r=N({},n),o=C(e());n=o,function t(e,n,i,r){var o=typeof i,f=typeof r;if(f===v)B(e,i);else if(o===v)D(r),n.remove();else if(function(t,e,n,i){return n!==i||t.e!==e.e||t.id!==e.id||(n===a||n===c)&&t!==e}(i,r,o,f))D(r),e.replaceChild(L(i),n);else if(o===p){var u;!function(t,e,n){q(e,"up");for(var i,r,o=Object.keys(e.a),f=o.length;f--;)if(r=e.a[o[f]],i=n.a[o[f]],o[f]===m){if(a=typeof(d=i),(s=typeof(u=r))===p&&a===p&&JSON.stringify(u)===JSON.stringify(d)||s===v&&a===v)continue;t.removeAttribute(o[f]),J(r,t)}else o[f]===l?(M(t,n.eid),I(n.eid),e.eid=k(),w(e.eid,r,t)):o[f]===b&&r!==i?t.value=r:typeof i!==v&&r===i||t.setAttribute(o[f],r);var u,d,s,a}(n,i,r);for(var d=r.c.length;d--&&typeof i.c[d]===v;)typeof(u=n.lastChild)===p&&(D(r.c[d]),u.remove());for(var s=0,h=i.c.length;s<h;s++)t(n,n.childNodes[s],i.c[s],r.c[s])}}(t,t.firstChild,o,r),_()}function B(t,e){t.appendChild(L(e))}function D(t){if(typeof t!==v&&(q(t,"un"),q(t,"d"),I(t.eid),g(t.c)))for(var e=t.c.length;e--;)D(t.c[e])}function I(t){typeof t===a&&delete u[t]}function M(t,e){for(var n=Object.keys(u[e]),i=n.length;i--;)s.includes(n[i])&&t.removeEventListener(n[i],u[e][n[i]])}function _(){for(var t;t=d.shift();)t()}function q(t,e){typeof t===p&&typeof t[e]===y&&d.push(t[e])}module.exports={component:x,render:j,h:O},exports.h=O,exports.render=j,exports.component=x; | ||
var t,e,n,i={},o={},r=[],u={},d=[],f=["abort","blur","error","focus","load","mouseenter","mouseleave","resize","scroll","unload"];function c(t){return Array.isArray(t)}function s(){return Math.random().toString(36).substring(2)+(new Date).getTime().toString(36)}function a(t,e){for(var n=0,i=e.length;n<i;n++)c(e[n])?a(t,e[n]):t.push(e[n]);return t}function h(t,e){for(var n in e)t[n]=e[n];return t}function v(t,e,n){return h(h(t,e),n)}function l(t,e){return{e:t,a:h({},e),c:a([],[].slice.call(arguments,2))}}function p(o,r,u){void 0===u&&(u={}),i=h({},u),e=o,t=document.getElementById(r),n=j(o()),C(t,n),J()}function y(t){var e=void 0===t?{}:t,n=e.name,r=void 0===n?"":n,u=e.state,d=void 0===u?{}:u,f=e.mounted,c=void 0===f?function(){}:f,a=e.updated,h=void 0===a?function(){}:a,v=e.unmounted,l=void 0===v?function(){}:v,p=e.methods,y=void 0===p?function(){}:p,j=e.render,S=void 0===j?function(){}:j,N=s();return function(t){return void 0===t&&(t={}),{id:N,init:function(){return this.id=N,this.name=r+(t.key?"_"+t.key:""),this.key=this.id+(this.name||""),this.props=t,this.store=i,this.getStore=b,this.setStore=m.bind(this),this.getState=g.bind(this),this.setState=k.bind(this),this.createState=function(){void 0===o[this.key]&&(o[this.key]=d)}.bind(this)(),this.deleteState=function(){delete o[this.key]}.bind(this),this.mounted=c.bind(this),this.updated=h.bind(this),this.unmounted=l.bind(this),function(t,e){for(var n in"function"==typeof e&&(e=e.bind(t)()),e)t[n]=e[n].bind(t)}(this,y),this.render=S.bind(this),this}}}}function b(){return h({},i)}function m(t,e){"function"==typeof t&&(t=t(i)),i=v({},i,t),x(),"function"==typeof e&&e.bind(this)()}function g(){return h({},o[this.key])}function k(t,e){"function"==typeof t&&(t=t(o[this.key])),o[this.key]=v({},o[this.key],t),x(),"function"==typeof e&&e.bind(this)()}function j(t){if(void 0===t)return t;if("function"==typeof t.e){var e=h({},t.a.props);delete t.a.props,t=t.e(e)}if("function"==typeof t.init){var n=new t.init;"object"==typeof(t=n.render())&&(t.id=n.id,t.m=n.mounted,t.up=n.updated,t.un=n.unmounted,t.d=n.deleteState)}if(c(t.c))for(var i=0,o=t.c.length;i<o;i++)t.c[i]=j(t.c[i]);return t}function S(t){var e=typeof t;if("string"===e||"number"===e)return document.createTextNode(t);if("boolean"===e||"undefined"===e)return document.createTextNode("");var n=document.createElement(t.e);if("object"==typeof t.a)for(var i=Object.keys(t.a),o=i.length;o--;)"events"===i[o]?(t.eid=s(),A(t.eid,t.a[i[o]],n)):"style"===i[o]?O(t.a[i[o]],n):n.setAttribute(i[o],t.a[i[o]]);if(z(t,"m"),c(t.c))for(var r=0,u=t.c.length;r<u;r++)C(n,t.c[r]);return n}function N(t){if("#document"!==t.parentNode.nodeName){var e=t.getAttribute("data-eid");return"string"==typeof e?e:N(t.parentNode)}}function A(e,n,i){i.setAttribute("data-eid",e),u[e]=n;for(var o=Object.keys(n),d=o.length;d--;)f.includes(o[d])?i.addEventListener(o[d],u[e][o[d]]):r.includes(o[d])||(r.push(o[d]),t.addEventListener(o[d],function(t){var e=N(t.target);if("string"==typeof e&&u[e]){var n=u[e][t.type];"function"==typeof n&&n(t)}}))}function O(t,e){if(void 0!==t)for(var n=Object.keys(t),i=n.length;i--;)e.style[n[i]]=t[n[i]]}function x(i){var o=h({},n),r=j(e());n=r,E(t,t.firstChild,r,o),J()}function E(t,e,n,i){var o=typeof n,r=typeof i;if("undefined"===r)C(t,n);else if("undefined"===o)L(i),e.remove();else if(function(t,e,n,i){return n!==i||t.e!==e.e||t.id!==e.id||("string"===n||"number"===n)&&t!==e}(n,i,o,r))L(i),t.replaceChild(S(n),e);else if("object"===o){var u;!function(t,e,n){z(e,"up");for(var i,o,r=Object.keys(e.a),u=r.length;u--;)if(o=e.a[r[u]],i=n.a[r[u]],"style"===r[u]){if(void 0,void 0,a=typeof(f=i),"object"==(c=typeof(d=o))&&"object"===a&&JSON.stringify(d)===JSON.stringify(f)||"undefined"===c&&"undefined"===a)continue;t.removeAttribute(r[u]),O(o,t)}else"events"===r[u]?(w(t,n.eid),T(n.eid),e.eid=s(),A(e.eid,o,t)):"value"===r[u]&&o!==i?t.value=o:void 0!==i&&o===i||t.setAttribute(r[u],o);var d,f,c,a}(e,n,i);for(var d=i.c.length;d--&&void 0===n.c[d];)"object"==typeof(u=e.lastChild)&&(L(i.c[d]),u.remove());for(var f=0,c=n.c.length;f<c;f++)E(e,e.childNodes[f],n.c[f],i.c[f])}}function C(t,e){t.appendChild(S(e))}function L(t){if(void 0!==t&&(z(t,"un"),z(t,"d"),T(t.eid),c(t.c)))for(var e=t.c.length;e--;)L(t.c[e])}function T(t){"string"==typeof t&&delete u[t]}function w(t,e){for(var n=Object.keys(u[e]),i=n.length;i--;)f.includes(n[i])&&t.removeEventListener(n[i],u[e][n[i]])}function J(){for(var t;t=d.shift();)t()}function z(t,e){"object"==typeof t&&"function"==typeof t[e]&&d.push(t[e])}module.exports={component:y,render:p,h:l},exports.component=y,exports.h=l,exports.render=p; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
var t,e,n,i={},r={},o="eid",f=[],u={},d=[],a=["abort","blur","error","focus","load","mouseenter","mouseleave","resize","scroll","unload"],s="string",c="number",h="boolean",v="undefined",p="object",y="function",l="events",m="style",b="value";function g(t){return Array.isArray(t)}function k(){return Math.random().toString(36).substring(2)+(new Date).getTime().toString(36)}function S(t,e){for(var n=0,i=e.length;n<i;n++)g(e[n])?S(t,e[n]):t.push(e[n]);return t}function N(t,e){for(var n in e)t[n]=e[n];return t}function A(t,e,n){return N(N(t,e),n)}function O(t,e){for(var n=[],i=arguments.length-2;i-- >0;)n[i]=arguments[i+2];return{e:t,a:N({},e),c:S([],n)}}function j(r,o,f){void 0===f&&(f={}),i=N({},f),e=r,t=document.getElementById(o),n=C(r()),B(t,n),_()}function E(t){void 0===t&&(t={});var e=t.name;void 0===e&&(e="");var n=t.state;void 0===n&&(n={});var o=t.mounted;void 0===o&&(o=function(){});var f=t.updated;void 0===f&&(f=function(){});var u=t.unmounted;void 0===u&&(u=function(){});var d=t.methods;void 0===d&&(d=function(){});var a=t.render;void 0===a&&(a=function(){});var s=k();return function(t){return void 0===t&&(t={}),{id:s,init:function(){return this.id=s,this.name=e+(t.key?"_"+t.key:""),this.key=this.id+(this.name||""),this.props=t,this.store=i,this.getStore=x,this.setStore=function(t,e){typeof t===y&&(t=t(i)),i=A({},i,t),z(),typeof e===y&&e.bind(this)()}.bind(this),this.getState=function(){return N({},r[this.key])}.bind(this),this.setState=function(t,e){typeof t===y&&(t=t(r[this.key])),r[this.key]=A({},r[this.key],t),z(),typeof e===y&&e.bind(this)()}.bind(this),this.createState=function(){typeof r[this.key]===v&&(r[this.key]=n)}.bind(this)(),this.deleteState=function(){delete r[this.key]}.bind(this),this.mounted=o.bind(this),this.updated=f.bind(this),this.unmounted=u.bind(this),function(t,e){for(var n in typeof e===y&&(e=e.bind(t)()),e)t[n]=e[n].bind(t)}(this,d),this.render=a.bind(this),this}}}}function x(){return N({},i)}function C(t){if(typeof t===v)return t;if(typeof t.e===y){var e=N({},t.a.props);delete t.a.props,t=t.e(e)}if(typeof t.init===y){var n=new t.init;typeof(t=n.render())===p&&(t.id=n.id,t.m=n.mounted,t.up=n.updated,t.un=n.unmounted,t.d=n.deleteState)}if(g(t.c))for(var i=0,r=t.c.length;i<r;i++)t.c[i]=C(t.c[i]);return t}function L(t){var e=typeof t;if(e===s||e===c)return document.createTextNode(t);if(e===h||e===v)return document.createTextNode("");var n=document.createElement(t.e);if(typeof t.a===p)for(var i=Object.keys(t.a),r=i.length;r--;)i[r]===l?(t.eid=k(),w(t.eid,t.a[i[r]],n)):i[r]===m?J(t.a[i[r]],n):n.setAttribute(i[r],t.a[i[r]]);if(q(t,"m"),g(t.c))for(var o=0,f=t.c.length;o<f;o++)B(n,t.c[o]);return n}function T(t){if("#document"!==t.parentNode.nodeName){var e=t.getAttribute("data-"+o);return typeof e===s?e:T(t.parentNode)}}function w(e,n,i){i.setAttribute("data-"+o,e),u[e]=n;for(var r=Object.keys(n),d=r.length;d--;)a.includes(r[d])?i.addEventListener(r[d],u[e][r[d]]):f.includes(r[d])||(f.push(r[d]),t.addEventListener(r[d],function(t){var e=T(t.target);if(typeof e===s&&u[e]){var n=u[e][t.type];typeof n===y&&n(t)}}))}function J(t,e){if(typeof t!==v)for(var n=Object.keys(t),i=n.length;i--;)e.style[n[i]]=t[n[i]]}function z(i){var r=N({},n),o=C(e());n=o,function t(e,n,i,r){var o=typeof i,f=typeof r;if(f===v)B(e,i);else if(o===v)D(r),n.remove();else if(function(t,e,n,i){return n!==i||t.e!==e.e||t.id!==e.id||(n===s||n===c)&&t!==e}(i,r,o,f))D(r),e.replaceChild(L(i),n);else if(o===p){var u;!function(t,e,n){q(e,"up");for(var i,r,o=Object.keys(e.a),f=o.length;f--;)if(r=e.a[o[f]],i=n.a[o[f]],o[f]===m){if(s=typeof(d=i),(a=typeof(u=r))===p&&s===p&&JSON.stringify(u)===JSON.stringify(d)||a===v&&s===v)continue;t.removeAttribute(o[f]),J(r,t)}else o[f]===l?(M(t,n.eid),I(n.eid),e.eid=k(),w(e.eid,r,t)):o[f]===b&&r!==i?t.value=r:typeof i!==v&&r===i||t.setAttribute(o[f],r);var u,d,a,s}(n,i,r);for(var d=r.c.length;d--&&typeof i.c[d]===v;)typeof(u=n.lastChild)===p&&(D(r.c[d]),u.remove());for(var a=0,h=i.c.length;a<h;a++)t(n,n.childNodes[a],i.c[a],r.c[a])}}(t,t.firstChild,o,r),_()}function B(t,e){t.appendChild(L(e))}function D(t){if(typeof t!==v&&(q(t,"un"),q(t,"d"),I(t.eid),g(t.c)))for(var e=t.c.length;e--;)D(t.c[e])}function I(t){typeof t===s&&delete u[t]}function M(t,e){for(var n=Object.keys(u[e]),i=n.length;i--;)a.includes(n[i])&&t.removeEventListener(n[i],u[e][n[i]])}function _(){for(var t;t=d.shift();)t()}function q(t,e){typeof t===p&&typeof t[e]===y&&d.push(t[e])}module.exports={component:E,render:j,h:O};export{O as h,j as render,E as component}; | ||
var t,e,n,i={},o={},r=[],u={},d=[],f=["abort","blur","error","focus","load","mouseenter","mouseleave","resize","scroll","unload"];function c(t){return Array.isArray(t)}function s(){return Math.random().toString(36).substring(2)+(new Date).getTime().toString(36)}function a(t,e){for(var n=0,i=e.length;n<i;n++)c(e[n])?a(t,e[n]):t.push(e[n]);return t}function h(t,e){for(var n in e)t[n]=e[n];return t}function v(t,e,n){return h(h(t,e),n)}function l(t,e){return{e:t,a:h({},e),c:a([],[].slice.call(arguments,2))}}function y(o,r,u){void 0===u&&(u={}),i=h({},u),e=o,t=document.getElementById(r),n=j(o()),C(t,n),J()}function p(t){var e=void 0===t?{}:t,n=e.name,r=void 0===n?"":n,u=e.state,d=void 0===u?{}:u,f=e.mounted,c=void 0===f?function(){}:f,a=e.updated,h=void 0===a?function(){}:a,v=e.unmounted,l=void 0===v?function(){}:v,y=e.methods,p=void 0===y?function(){}:y,j=e.render,S=void 0===j?function(){}:j,N=s();return function(t){return void 0===t&&(t={}),{id:N,init:function(){return this.id=N,this.name=r+(t.key?"_"+t.key:""),this.key=this.id+(this.name||""),this.props=t,this.store=i,this.getStore=b,this.setStore=m.bind(this),this.getState=g.bind(this),this.setState=k.bind(this),this.createState=function(){void 0===o[this.key]&&(o[this.key]=d)}.bind(this)(),this.deleteState=function(){delete o[this.key]}.bind(this),this.mounted=c.bind(this),this.updated=h.bind(this),this.unmounted=l.bind(this),function(t,e){for(var n in"function"==typeof e&&(e=e.bind(t)()),e)t[n]=e[n].bind(t)}(this,p),this.render=S.bind(this),this}}}}function b(){return h({},i)}function m(t,e){"function"==typeof t&&(t=t(i)),i=v({},i,t),E(),"function"==typeof e&&e.bind(this)()}function g(){return h({},o[this.key])}function k(t,e){"function"==typeof t&&(t=t(o[this.key])),o[this.key]=v({},o[this.key],t),E(),"function"==typeof e&&e.bind(this)()}function j(t){if(void 0===t)return t;if("function"==typeof t.e){var e=h({},t.a.props);delete t.a.props,t=t.e(e)}if("function"==typeof t.init){var n=new t.init;"object"==typeof(t=n.render())&&(t.id=n.id,t.m=n.mounted,t.up=n.updated,t.un=n.unmounted,t.d=n.deleteState)}if(c(t.c))for(var i=0,o=t.c.length;i<o;i++)t.c[i]=j(t.c[i]);return t}function S(t){var e=typeof t;if("string"===e||"number"===e)return document.createTextNode(t);if("boolean"===e||"undefined"===e)return document.createTextNode("");var n=document.createElement(t.e);if("object"==typeof t.a)for(var i=Object.keys(t.a),o=i.length;o--;)"events"===i[o]?(t.eid=s(),A(t.eid,t.a[i[o]],n)):"style"===i[o]?O(t.a[i[o]],n):n.setAttribute(i[o],t.a[i[o]]);if(z(t,"m"),c(t.c))for(var r=0,u=t.c.length;r<u;r++)C(n,t.c[r]);return n}function N(t){if("#document"!==t.parentNode.nodeName){var e=t.getAttribute("data-eid");return"string"==typeof e?e:N(t.parentNode)}}function A(e,n,i){i.setAttribute("data-eid",e),u[e]=n;for(var o=Object.keys(n),d=o.length;d--;)f.includes(o[d])?i.addEventListener(o[d],u[e][o[d]]):r.includes(o[d])||(r.push(o[d]),t.addEventListener(o[d],function(t){var e=N(t.target);if("string"==typeof e&&u[e]){var n=u[e][t.type];"function"==typeof n&&n(t)}}))}function O(t,e){if(void 0!==t)for(var n=Object.keys(t),i=n.length;i--;)e.style[n[i]]=t[n[i]]}function E(i){var o=h({},n),r=j(e());n=r,x(t,t.firstChild,r,o),J()}function x(t,e,n,i){var o=typeof n,r=typeof i;if("undefined"===r)C(t,n);else if("undefined"===o)L(i),e.remove();else if(function(t,e,n,i){return n!==i||t.e!==e.e||t.id!==e.id||("string"===n||"number"===n)&&t!==e}(n,i,o,r))L(i),t.replaceChild(S(n),e);else if("object"===o){var u;!function(t,e,n){z(e,"up");for(var i,o,r=Object.keys(e.a),u=r.length;u--;)if(o=e.a[r[u]],i=n.a[r[u]],"style"===r[u]){if(void 0,void 0,a=typeof(f=i),"object"==(c=typeof(d=o))&&"object"===a&&JSON.stringify(d)===JSON.stringify(f)||"undefined"===c&&"undefined"===a)continue;t.removeAttribute(r[u]),O(o,t)}else"events"===r[u]?(w(t,n.eid),T(n.eid),e.eid=s(),A(e.eid,o,t)):"value"===r[u]&&o!==i?t.value=o:void 0!==i&&o===i||t.setAttribute(r[u],o);var d,f,c,a}(e,n,i);for(var d=i.c.length;d--&&void 0===n.c[d];)"object"==typeof(u=e.lastChild)&&(L(i.c[d]),u.remove());for(var f=0,c=n.c.length;f<c;f++)x(e,e.childNodes[f],n.c[f],i.c[f])}}function C(t,e){t.appendChild(S(e))}function L(t){if(void 0!==t&&(z(t,"un"),z(t,"d"),T(t.eid),c(t.c)))for(var e=t.c.length;e--;)L(t.c[e])}function T(t){"string"==typeof t&&delete u[t]}function w(t,e){for(var n=Object.keys(u[e]),i=n.length;i--;)f.includes(n[i])&&t.removeEventListener(n[i],u[e][n[i]])}function J(){for(var t;t=d.shift();)t()}function z(t,e){"object"==typeof t&&"function"==typeof t[e]&&d.push(t[e])}module.exports={component:p,render:y,h:l};export{p as component,l as h,y as render}; | ||
//# sourceMappingURL=index.m.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.literaljs={})}(this,function(e){var t,n,i,o={},r={},f="eid",u=[],d={},s=[],a=["abort","blur","error","focus","load","mouseenter","mouseleave","resize","scroll","unload"],c="string",h="number",p="boolean",v="undefined",y="object",l="function",m="events",b="style",g="value";function k(e){return Array.isArray(e)}function S(){return Math.random().toString(36).substring(2)+(new Date).getTime().toString(36)}function j(e,t){for(var n=0,i=t.length;n<i;n++)k(t[n])?j(e,t[n]):e.push(t[n]);return e}function N(e,t){for(var n in t)e[n]=t[n];return e}function A(e,t,n){return N(N(e,t),n)}function O(e,t){for(var n=[],i=arguments.length-2;i-- >0;)n[i]=arguments[i+2];return{e:e,a:N({},t),c:j([],n)}}function x(e,r,f){void 0===f&&(f={}),o=N({},f),n=e,t=document.getElementById(r),i=L(e()),D(t,i),q()}function E(e){void 0===e&&(e={});var t=e.name;void 0===t&&(t="");var n=e.state;void 0===n&&(n={});var i=e.mounted;void 0===i&&(i=function(){});var f=e.updated;void 0===f&&(f=function(){});var u=e.unmounted;void 0===u&&(u=function(){});var d=e.methods;void 0===d&&(d=function(){});var s=e.render;void 0===s&&(s=function(){});var a=S();return function(e){return void 0===e&&(e={}),{id:a,init:function(){return this.id=a,this.name=t+(e.key?"_"+e.key:""),this.key=this.id+(this.name||""),this.props=e,this.store=o,this.getStore=C,this.setStore=function(e,t){typeof e===l&&(e=e(o)),o=A({},o,e),B(),typeof t===l&&t.bind(this)()}.bind(this),this.getState=function(){return N({},r[this.key])}.bind(this),this.setState=function(e,t){typeof e===l&&(e=e(r[this.key])),r[this.key]=A({},r[this.key],e),B(),typeof t===l&&t.bind(this)()}.bind(this),this.createState=function(){typeof r[this.key]===v&&(r[this.key]=n)}.bind(this)(),this.deleteState=function(){delete r[this.key]}.bind(this),this.mounted=i.bind(this),this.updated=f.bind(this),this.unmounted=u.bind(this),function(e,t){for(var n in typeof t===l&&(t=t.bind(e)()),t)e[n]=t[n].bind(e)}(this,d),this.render=s.bind(this),this}}}}function C(){return N({},o)}function L(e){if(typeof e===v)return e;if(typeof e.e===l){var t=N({},e.a.props);delete e.a.props,e=e.e(t)}if(typeof e.init===l){var n=new e.init;typeof(e=n.render())===y&&(e.id=n.id,e.m=n.mounted,e.up=n.updated,e.un=n.unmounted,e.d=n.deleteState)}if(k(e.c))for(var i=0,o=e.c.length;i<o;i++)e.c[i]=L(e.c[i]);return e}function T(e){var t=typeof e;if(t===c||t===h)return document.createTextNode(e);if(t===p||t===v)return document.createTextNode("");var n=document.createElement(e.e);if(typeof e.a===y)for(var i=Object.keys(e.a),o=i.length;o--;)i[o]===m?(e.eid=S(),J(e.eid,e.a[i[o]],n)):i[o]===b?z(e.a[i[o]],n):n.setAttribute(i[o],e.a[i[o]]);if(F(e,"m"),k(e.c))for(var r=0,f=e.c.length;r<f;r++)D(n,e.c[r]);return n}function w(e){if("#document"!==e.parentNode.nodeName){var t=e.getAttribute("data-"+f);return typeof t===c?t:w(e.parentNode)}}function J(e,n,i){i.setAttribute("data-"+f,e),d[e]=n;for(var o=Object.keys(n),r=o.length;r--;)a.includes(o[r])?i.addEventListener(o[r],d[e][o[r]]):u.includes(o[r])||(u.push(o[r]),t.addEventListener(o[r],function(e){var t=w(e.target);if(typeof t===c&&d[t]){var n=d[t][e.type];typeof n===l&&n(e)}}))}function z(e,t){if(typeof e!==v)for(var n=Object.keys(e),i=n.length;i--;)t.style[n[i]]=e[n[i]]}function B(e){var o=N({},i),r=L(n());i=r,function e(t,n,i,o){var r=typeof i,f=typeof o;if(f===v)D(t,i);else if(r===v)I(o),n.remove();else if(function(e,t,n,i){return n!==i||e.e!==t.e||e.id!==t.id||(n===c||n===h)&&e!==t}(i,o,r,f))I(o),t.replaceChild(T(i),n);else if(r===y){var u;!function(e,t,n){F(t,"up");for(var i,o,r=Object.keys(t.a),f=r.length;f--;)if(o=t.a[r[f]],i=n.a[r[f]],r[f]===b){if(a=typeof(d=i),(s=typeof(u=o))===y&&a===y&&JSON.stringify(u)===JSON.stringify(d)||s===v&&a===v)continue;e.removeAttribute(r[f]),z(o,e)}else r[f]===m?(_(e,n.eid),M(n.eid),t.eid=S(),J(t.eid,o,e)):r[f]===g&&o!==i?e.value=o:typeof i!==v&&o===i||e.setAttribute(r[f],o);var u,d,s,a}(n,i,o);for(var d=o.c.length;d--&&typeof i.c[d]===v;)typeof(u=n.lastChild)===y&&(I(o.c[d]),u.remove());for(var s=0,a=i.c.length;s<a;s++)e(n,n.childNodes[s],i.c[s],o.c[s])}}(t,t.firstChild,r,o),q()}function D(e,t){e.appendChild(T(t))}function I(e){if(typeof e!==v&&(F(e,"un"),F(e,"d"),M(e.eid),k(e.c)))for(var t=e.c.length;t--;)I(e.c[t])}function M(e){typeof e===c&&delete d[e]}function _(e,t){for(var n=Object.keys(d[t]),i=n.length;i--;)a.includes(n[i])&&e.removeEventListener(n[i],d[t][n[i]])}function q(){for(var e;e=s.shift();)e()}function F(e,t){typeof e===y&&typeof e[t]===l&&s.push(e[t])}module.exports={component:E,render:x,h:O},e.h=O,e.render=x,e.component=E}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e||self).literaljs={})}(this,function(e){var t,n,i,o={},r={},f=[],d={},u=[],s=["abort","blur","error","focus","load","mouseenter","mouseleave","resize","scroll","unload"],c="string",a="number",h="undefined",p="object",l="function",y="events",v="style";function m(e){return Array.isArray(e)}function b(){return Math.random().toString(36).substring(2)+(new Date).getTime().toString(36)}function g(e,t){for(var n=0,i=t.length;n<i;n++)m(t[n])?g(e,t[n]):e.push(t[n]);return e}function k(e,t){for(var n in t)e[n]=t[n];return e}function S(e,t,n){return k(k(e,t),n)}function j(e,t){return{e:e,a:k({},t),c:g([],[].slice.call(arguments,2))}}function N(e,r,f){void 0===f&&(f={}),o=k({},f),n=e,t=document.getElementById(r),i=C(e()),I(t,i),F()}function A(e){var t=void 0===e?{}:e,n=t.name,i=void 0===n?"":n,f=t.state,d=void 0===f?{}:f,u=t.mounted,s=void 0===u?function(){}:u,c=t.updated,a=void 0===c?function(){}:c,p=t.unmounted,y=void 0===p?function(){}:p,v=t.methods,m=void 0===v?function(){}:v,g=t.render,k=void 0===g?function(){}:g,S=b();return function(e){return void 0===e&&(e={}),{id:S,init:function(){return this.id=S,this.name=i+(e.key?"_"+e.key:""),this.key=this.id+(this.name||""),this.props=e,this.store=o,this.getStore=O,this.setStore=x.bind(this),this.getState=E.bind(this),this.setState=T.bind(this),this.createState=function(){typeof r[this.key]===h&&(r[this.key]=d)}.bind(this)(),this.deleteState=function(){delete r[this.key]}.bind(this),this.mounted=s.bind(this),this.updated=a.bind(this),this.unmounted=y.bind(this),function(e,t){for(var n in typeof t===l&&(t=t.bind(e)()),t)e[n]=t[n].bind(e)}(this,m),this.render=k.bind(this),this}}}}function O(){return k({},o)}function x(e,t){typeof e===l&&(e=e(o)),o=S({},o,e),B(),typeof t===l&&t.bind(this)()}function E(){return k({},r[this.key])}function T(e,t){typeof e===l&&(e=e(r[this.key])),r[this.key]=S({},r[this.key],e),B(),typeof t===l&&t.bind(this)()}function C(e){if(typeof e===h)return e;if(typeof e.e===l){var t=k({},e.a.props);delete e.a.props,e=e.e(t)}if(typeof e.init===l){var n=new e.init;typeof(e=n.render())===p&&(e.id=n.id,e.m=n.mounted,e.up=n.updated,e.un=n.unmounted,e.d=n.deleteState)}if(m(e.c))for(var i=0,o=e.c.length;i<o;i++)e.c[i]=C(e.c[i]);return e}function L(e){var t=typeof e;if(t===c||t===a)return document.createTextNode(e);if("boolean"===t||t===h)return document.createTextNode("");var n=document.createElement(e.e);if(typeof e.a===p)for(var i=Object.keys(e.a),o=i.length;o--;)i[o]===y?(e.eid=b(),J(e.eid,e.a[i[o]],n)):i[o]===v?z(e.a[i[o]],n):n.setAttribute(i[o],e.a[i[o]]);if(G(e,"m"),m(e.c))for(var r=0,f=e.c.length;r<f;r++)I(n,e.c[r]);return n}function w(e){if("#document"!==e.parentNode.nodeName){var t=e.getAttribute("data-eid");return typeof t===c?t:w(e.parentNode)}}function J(e,n,i){i.setAttribute("data-eid",e),d[e]=n;for(var o=Object.keys(n),r=o.length;r--;)s.includes(o[r])?i.addEventListener(o[r],d[e][o[r]]):f.includes(o[r])||(f.push(o[r]),t.addEventListener(o[r],function(e){var t=w(e.target);if(typeof t===c&&d[t]){var n=d[t][e.type];typeof n===l&&n(e)}}))}function z(e,t){if(typeof e!==h)for(var n=Object.keys(e),i=n.length;i--;)t.style[n[i]]=e[n[i]]}function B(e){var o=k({},i),r=C(n());i=r,D(t,t.firstChild,r,o),F()}function D(e,t,n,i){var o=typeof n,r=typeof i;if(r===h)I(e,n);else if(o===h)M(i),t.remove();else if(function(e,t,n,i){return n!==i||e.e!==t.e||e.id!==t.id||(n===c||n===a)&&e!==t}(n,i,o,r))M(i),e.replaceChild(L(n),t);else if(o===p){var f;!function(e,t,n){G(t,"up");for(var i,o,r=Object.keys(t.a),f=r.length;f--;)if(o=t.a[r[f]],i=n.a[r[f]],r[f]===v){if(void 0,void 0,c=typeof(u=i),(s=typeof(d=o))===p&&c===p&&JSON.stringify(d)===JSON.stringify(u)||s===h&&c===h)continue;e.removeAttribute(r[f]),z(o,e)}else r[f]===y?(q(e,n.eid),_(n.eid),t.eid=b(),J(t.eid,o,e)):"value"===r[f]&&o!==i?e.value=o:typeof i!==h&&o===i||e.setAttribute(r[f],o);var d,u,s,c}(t,n,i);for(var d=i.c.length;d--&&typeof n.c[d]===h;)typeof(f=t.lastChild)===p&&(M(i.c[d]),f.remove());for(var u=0,s=n.c.length;u<s;u++)D(t,t.childNodes[u],n.c[u],i.c[u])}}function I(e,t){e.appendChild(L(t))}function M(e){if(typeof e!==h&&(G(e,"un"),G(e,"d"),_(e.eid),m(e.c)))for(var t=e.c.length;t--;)M(e.c[t])}function _(e){typeof e===c&&delete d[e]}function q(e,t){for(var n=Object.keys(d[t]),i=n.length;i--;)s.includes(n[i])&&e.removeEventListener(n[i],d[t][n[i]])}function F(){for(var e;e=u.shift();)e()}function G(e,t){typeof e===p&&typeof e[t]===l&&u.push(e[t])}module.exports={component:A,render:N,h:j},e.component=A,e.h=j,e.render=N}); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "literaljs", | ||
"version": "7.0.1", | ||
"version": "7.0.2", | ||
"description": "A small JavaScript library for building reactive user interfaces.", | ||
@@ -17,4 +17,7 @@ "main": "build/index.js", | ||
"license": "MIT", | ||
"jest": { | ||
"verbose": true | ||
}, | ||
"babel": { | ||
"presets": "env" | ||
"presets": ["@babel/preset-env"] | ||
}, | ||
@@ -24,5 +27,5 @@ "dependencies": {}, | ||
"babel-preset-env": "^1.7.0", | ||
"jest": "^24.8.0", | ||
"microbundle": "^0.11.0" | ||
"jest": "^26.6.3", | ||
"microbundle": "^0.13.0" | ||
} | ||
} |
@@ -12,3 +12,3 @@ <p align="center"> | ||
Recent 7.0.1 microbundle: | ||
Recent 7.0.2 microbundle: | ||
```js | ||
@@ -15,0 +15,0 @@ Build "literaljs" to build: |
@@ -9,12 +9,12 @@ import { component, h } from '../src'; | ||
} | ||
})(); | ||
})().init(); | ||
expect(new Comp.render()).toEqual({ | ||
element: 'div', | ||
attributes: {}, | ||
children: [ | ||
expect(Comp.render()).toEqual({ | ||
e: 'div', | ||
a: {}, | ||
c: [ | ||
{ | ||
element: 'span', | ||
attributes: {}, | ||
children: ['Hello World'] | ||
e: 'span', | ||
a: {}, | ||
c: ['Hello World'] | ||
} | ||
@@ -31,12 +31,12 @@ ] | ||
} | ||
})({ count: count }); | ||
})({ count: count }).init(); | ||
expect(new Comp.render()).toEqual({ | ||
element: 'div', | ||
attributes: {}, | ||
children: [ | ||
expect(Comp.render()).toEqual({ | ||
e: 'div', | ||
a: {}, | ||
c: [ | ||
{ | ||
element: 'span', | ||
attributes: {}, | ||
children: [count] | ||
e: 'span', | ||
a: {}, | ||
c: [count] | ||
} | ||
@@ -56,12 +56,12 @@ ] | ||
} | ||
})(); | ||
})().init(); | ||
expect(new Comp.render()).toEqual({ | ||
element: 'div', | ||
attributes: {}, | ||
children: [ | ||
expect(Comp.render()).toEqual({ | ||
e: 'div', | ||
a: {}, | ||
c: [ | ||
{ | ||
element: 'span', | ||
attributes: {}, | ||
children: [count] | ||
e: 'span', | ||
a: {}, | ||
c: [count] | ||
} | ||
@@ -85,11 +85,11 @@ ] | ||
} | ||
})(); | ||
expect(new Comp.render()).toEqual({ | ||
element: 'div', | ||
attributes: {}, | ||
children: [ | ||
})().init(); | ||
expect(Comp.render()).toEqual({ | ||
e: 'div', | ||
a: {}, | ||
c: [ | ||
{ | ||
element: 'span', | ||
attributes: {}, | ||
children: [count] | ||
e: 'span', | ||
a: {}, | ||
c: [count] | ||
} | ||
@@ -96,0 +96,0 @@ ] |
@@ -6,5 +6,5 @@ import { h } from '../src'; | ||
expect(h('div')).toEqual({ | ||
element: 'div', | ||
attributes: {}, | ||
children: [] | ||
e: 'div', | ||
a: {}, | ||
c: [] | ||
}); | ||
@@ -15,11 +15,11 @@ }); | ||
expect(h('div', {}, ['hello'])).toEqual({ | ||
element: 'div', | ||
attributes: {}, | ||
children: ['hello'] | ||
e: 'div', | ||
a: {}, | ||
c: ['hello'] | ||
}); | ||
expect(h('div', {}, 'world')).toEqual({ | ||
element: 'div', | ||
attributes: {}, | ||
children: ['world'] | ||
e: 'div', | ||
a: {}, | ||
c: ['world'] | ||
}); | ||
@@ -30,35 +30,35 @@ }); | ||
expect(h('div', {}, ['foo', 'bar', 'baz'])).toEqual({ | ||
element: 'div', | ||
attributes: {}, | ||
children: ['foo', 'bar', 'baz'] | ||
e: 'div', | ||
a: {}, | ||
c: ['foo', 'bar', 'baz'] | ||
}); | ||
expect(h('div', {}, 'foo', 'bar', 'baz')).toEqual({ | ||
element: 'div', | ||
attributes: {}, | ||
children: ['foo', 'bar', 'baz'] | ||
e: 'div', | ||
a: {}, | ||
c: ['foo', 'bar', 'baz'] | ||
}); | ||
expect(h('div', {}, [0, 1, 2, 3, 4])).toEqual({ | ||
element: 'div', | ||
attributes: {}, | ||
children: [0, 1, 2, 3, 4] | ||
e: 'div', | ||
a: {}, | ||
c: [0, 1, 2, 3, 4] | ||
}); | ||
expect(h('div', {}, 0, 1, 2, 3, 4)).toEqual({ | ||
element: 'div', | ||
attributes: {}, | ||
children: [0, 1, 2, 3, 4] | ||
e: 'div', | ||
a: {}, | ||
c: [0, 1, 2, 3, 4] | ||
}); | ||
expect(h('div', {}, ['foo', 1, 'baz'])).toEqual({ | ||
element: 'div', | ||
attributes: {}, | ||
children: ['foo', 1, 'baz'] | ||
e: 'div', | ||
a: {}, | ||
c: ['foo', 1, 'baz'] | ||
}); | ||
expect(h('div', {}, 'foo', 1, 'baz')).toEqual({ | ||
element: 'div', | ||
attributes: {}, | ||
children: ['foo', 1, 'baz'] | ||
e: 'div', | ||
a: {}, | ||
c: ['foo', 1, 'baz'] | ||
}); | ||
@@ -69,14 +69,14 @@ | ||
).toEqual({ | ||
element: 'div', | ||
attributes: {}, | ||
children: [ | ||
e: 'div', | ||
a: {}, | ||
c: [ | ||
{ | ||
element: 'div', | ||
attributes: {}, | ||
children: ['hello'] | ||
e: 'div', | ||
a: {}, | ||
c: ['hello'] | ||
}, | ||
{ | ||
element: 'div', | ||
attributes: {}, | ||
children: ['world'] | ||
e: 'div', | ||
a: {}, | ||
c: ['world'] | ||
} | ||
@@ -87,14 +87,14 @@ ] | ||
expect(h('div', {}, h('div', {}, 'hello'), h('div', {}, 'world'))).toEqual({ | ||
element: 'div', | ||
attributes: {}, | ||
children: [ | ||
e: 'div', | ||
a: {}, | ||
c: [ | ||
{ | ||
element: 'div', | ||
attributes: {}, | ||
children: ['hello'] | ||
e: 'div', | ||
a: {}, | ||
c: ['hello'] | ||
}, | ||
{ | ||
element: 'div', | ||
attributes: {}, | ||
children: ['world'] | ||
e: 'div', | ||
a: {}, | ||
c: ['world'] | ||
} | ||
@@ -114,11 +114,11 @@ ] | ||
).toEqual({ | ||
element: 'div', | ||
attributes: {}, | ||
children: [ | ||
e: 'div', | ||
a: {}, | ||
c: [ | ||
'foo', | ||
'bar', | ||
{ | ||
element: 'div', | ||
attributes: {}, | ||
children: ['hello'] | ||
e: 'div', | ||
a: {}, | ||
c: ['hello'] | ||
}, | ||
@@ -128,5 +128,5 @@ 1, | ||
{ | ||
element: 'div', | ||
attributes: {}, | ||
children: ['world'] | ||
e: 'div', | ||
a: {}, | ||
c: ['world'] | ||
} | ||
@@ -148,11 +148,11 @@ ] | ||
).toEqual({ | ||
element: 'div', | ||
attributes: {}, | ||
children: [ | ||
e: 'div', | ||
a: {}, | ||
c: [ | ||
'foo', | ||
'bar', | ||
{ | ||
element: 'div', | ||
attributes: {}, | ||
children: ['hello'] | ||
e: 'div', | ||
a: {}, | ||
c: ['hello'] | ||
}, | ||
@@ -162,5 +162,5 @@ 1, | ||
{ | ||
element: 'div', | ||
attributes: {}, | ||
children: ['world'] | ||
e: 'div', | ||
a: {}, | ||
c: ['world'] | ||
} | ||
@@ -181,7 +181,7 @@ ] | ||
).toEqual({ | ||
element: 'div', | ||
attributes: { | ||
e: 'div', | ||
a: { | ||
class: 'container' | ||
}, | ||
children: ['!'] | ||
c: ['!'] | ||
}); | ||
@@ -201,8 +201,8 @@ | ||
).toEqual({ | ||
element: 'div', | ||
attributes: { | ||
e: 'div', | ||
a: { | ||
class: 'container', | ||
id: 'foo' | ||
}, | ||
children: [1, 2, 3] | ||
c: [1, 2, 3] | ||
}); | ||
@@ -213,7 +213,7 @@ }); | ||
expect(h('div', {}, [['foo'], ['bar'], ['baz']])).toEqual({ | ||
element: 'div', | ||
attributes: {}, | ||
children: ['foo', 'bar', 'baz'] | ||
e: 'div', | ||
a: {}, | ||
c: ['foo', 'bar', 'baz'] | ||
}); | ||
}); | ||
}); |
@@ -8,5 +8,11 @@ import { render, component, h } from '../src'; | ||
test('Lifecycle mounted works with getState and setState', () => { | ||
test('Lifecycle mounted works with getState and setState', (done) => { | ||
const Comp2 = component({ | ||
state: { show: false, count: 1 }, | ||
mounted() { | ||
this.setState({ count: this.getState().count + 1 }); | ||
const { count } = this.getState(); | ||
expect(count).toBe(2); | ||
done(); | ||
}, | ||
render() { | ||
@@ -20,9 +26,2 @@ return h( | ||
this.setState({ show: !this.getState().show }); | ||
setTimeout(() => { | ||
expect( | ||
document.getElementById('count') | ||
.innerHTML | ||
).toBe('2'); | ||
done(); | ||
}); | ||
} | ||
@@ -32,15 +31,5 @@ } | ||
this.getState().show && | ||
h( | ||
'span', | ||
{ | ||
events: { | ||
mounted: () => { | ||
this.setState({ | ||
count: this.getState().count + 1 | ||
}); | ||
} | ||
} | ||
}, | ||
h('span', { id: 'count' }, this.getState().count) | ||
) | ||
h('span', {}, [ | ||
h('span', { id: 'count' }, this.getState().count) | ||
]) | ||
); | ||
@@ -61,31 +50,16 @@ } | ||
test('Lifecycle unmounted works with getState and setState', () => { | ||
test('Lifecycle unmounted works with getState and setState', (done) => { | ||
const Comp2 = component({ | ||
state: { show: true, count: 1 }, | ||
state: { count: 1 }, | ||
unmounted() { | ||
expect(this.getState().count).toBe(1); | ||
done(); | ||
}, | ||
render() { | ||
return h( | ||
'button', | ||
{ | ||
id: 'button', | ||
events: { | ||
mounted: () => { | ||
this.setState({ show: !this.getState().show }); | ||
expect( | ||
document.getElementById('count').innerHTML | ||
).toBe('2'); | ||
done(); | ||
} | ||
} | ||
}, | ||
this.getState().show && | ||
h('span', { | ||
events: { | ||
unmounted: () => { | ||
this.setState({ | ||
count: this.getState().count + 1 | ||
}); | ||
} | ||
} | ||
}), | ||
h('span', { id: 'count' }, this.getState().count) | ||
'div', | ||
{ }, | ||
h('span', {}), [ | ||
h('span', { id: 'count' }, this.getState().count) | ||
] | ||
); | ||
@@ -96,3 +70,11 @@ } | ||
const Comp = component({ | ||
render: () => h('div', { class: 'container' }, Comp2()) | ||
state: { show: true }, | ||
mounted() { | ||
this.setState({ show: !this.getState().show }); | ||
}, | ||
render() { | ||
return h('div', { class: 'container' }, [ | ||
this.getState().show && Comp2() | ||
]); | ||
} | ||
}); | ||
@@ -102,2 +84,38 @@ | ||
}); | ||
test('Lifecycle updated works with getState and setState', (done) => { | ||
const Comp2 = component({ | ||
state: { count: 1 }, | ||
mounted() { | ||
this.setState((state) => ({ count: state.count + 1 })); | ||
}, | ||
updated() { | ||
expect(this.getState().count).toBe(2); | ||
done(); | ||
}, | ||
render() { | ||
return h( | ||
'div', | ||
{ }, | ||
h('span', {}), [ | ||
h('span', { id: 'count' }, this.getState().count) | ||
] | ||
); | ||
} | ||
}); | ||
const Comp = component({ | ||
state: { show: false }, | ||
mounted() { | ||
this.setState({ show: !this.getState().show }); | ||
}, | ||
render() { | ||
return h('div', { class: 'container' }, [ | ||
this.getState().show && Comp2() | ||
]); | ||
} | ||
}); | ||
render(Comp, 'root', {}); | ||
}); | ||
}); |
import { render, component, h } from '../src'; | ||
describe('Render Tests', () => { | ||
beforeAll((done) => { | ||
done(); | ||
}); | ||
test('Render Mounts Properly', () => { | ||
@@ -14,9 +18,6 @@ document.body.innerHTML = '<div id="root"></div>'; | ||
render(Comp, 'root', {}); | ||
console.log( | ||
'RENDER MOUNTS: ', | ||
document.getElementById('container').innerText | ||
); | ||
expect(document.getElementById('container').innerText).toEqual( | ||
'Hello World' | ||
); | ||
const containerHTML = document.getElementById('container').innerHTML; | ||
expect(containerHTML).toEqual('Hello World'); | ||
}); | ||
@@ -39,3 +40,5 @@ | ||
expect(document.getElementById('count').innerText).toEqual('1'); | ||
const count = document.getElementById('count').innerHTML; | ||
expect(count).toEqual('1'); | ||
}); | ||
@@ -61,3 +64,5 @@ | ||
expect(document.getElementById('count').innerText).toEqual('1'); | ||
const count = document.getElementById('count').innerHTML; | ||
expect(count).toEqual('1'); | ||
}); | ||
@@ -72,3 +77,3 @@ | ||
return h('div', { class: 'container' }, [ | ||
this.getState().show && h('span', {}, 'Hello World') | ||
this.getState().show && h('span', { id: 'hello' }, 'Hello World') | ||
]); | ||
@@ -80,5 +85,5 @@ } | ||
expect(document.getElementById('container').innerText).toEqual( | ||
'Hello World' | ||
); | ||
const containerHTML = document.getElementById('hello').innerHTML; | ||
expect(containerHTML).toEqual('Hello World'); | ||
}); | ||
@@ -101,6 +106,8 @@ | ||
expect(document.getElementById('hello')).toBe(null); | ||
const element = document.getElementById('hello'); | ||
expect(element).toBe(null); | ||
}); | ||
test('getState and setState Works With Methods', done => { | ||
test('getState and setState Works With Methods', () => { | ||
document.body.innerHTML = '<div id="root"></div>'; | ||
@@ -113,3 +120,6 @@ | ||
increment() { | ||
this.setState({ count: this.getState().count + 1 }); | ||
this.setState((state) => ({ count: state.count + 1 })); | ||
}, | ||
currentCount() { | ||
return this.getState().count; | ||
} | ||
@@ -126,8 +136,14 @@ }; | ||
this.increment(); | ||
expect(this.getState().count).toBe(2); | ||
done(); | ||
} | ||
} | ||
setTimeout(() => { | ||
const countHTML = document.getElementById('count').innerHTML; | ||
expect(countHTML).toBe('2'); | ||
done(); | ||
}); | ||
}, | ||
}, | ||
}, | ||
'Click Me' | ||
[ | ||
'Click Me', | ||
h('span', { id: 'count' }, this.currentCount()) | ||
] | ||
); | ||
@@ -148,3 +164,3 @@ } | ||
test('getState and setState Works In Render Event', done => { | ||
test('getState and setState Works In Render Event', () => { | ||
document.body.innerHTML = '<div id="root"></div>'; | ||
@@ -161,14 +177,17 @@ | ||
click: () => { | ||
this.setState({ | ||
count: this.getState().count + 1 | ||
this.setState((state) => ({ count: state.count + 1 })); | ||
setTimeout(() => { | ||
const countHTML = document.getElementById('count').innerHTML; | ||
expect(countHTML).toBe('2'); | ||
done(); | ||
}); | ||
var count = this.getState().count; | ||
expect(count).toBe(2); | ||
done(); | ||
} | ||
} | ||
}, | ||
}, | ||
}, | ||
'Click Me' | ||
[ | ||
'Click Me', | ||
h('span', { id: 'count' }, this.getState().count), | ||
] | ||
); | ||
} | ||
}, | ||
}); | ||
@@ -179,3 +198,3 @@ | ||
return h('div', { class: 'container' }, Comp2()); | ||
} | ||
}, | ||
}); | ||
@@ -182,0 +201,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
276720
18
617