Comparing version 2.5.1 to 3.0.0
@@ -1,2 +0,2 @@ | ||
var e,n,t,r={},i=[],o=[];function d(e){return void 0===e&&(e=r),Object.assign({},e)}function u(o){var u=Object.assign({},d(),o);r=u,i.push(u),function(){var r=i.pop(),o=c(n(),r),d=Object.assign({},t);t=Object.assign({},o),function e(n,t,r,i){void 0===i&&(i=0);if(!n)return;var o=n.childNodes[i];if(void 0===r)return n.appendChild(a(t)),void v(t,"mounted");if(!1===r)return n.replaceChild(a(t),o),void v(t,"mounted");if(!1===t)return n.replaceChild(a(t),o),void v(r,"unmounted");if(void 0===t)return n.removeChild(o),void v(r,"unmounted");if(function(e,n){var t=typeof e;return t!==typeof n||"string"===t&&e!==n||e.element!==n.element}(t,r))return n.replaceChild(a(t,{mount:!1}),o),void v(t,"mounted");if(t.element&&(function(e,n,t,r){for(var i=0,o=Object.entries(t);i<o.length;i+=1){var d=o[i],u=d[0],c=d[1],a=r[u];["children","events"].includes(u)||a&&c===a||(n.setAttribute(u,c),v(t,"updated"))}}(0,o,t,r),t.children||r.children))for(var d=0;d<(c=r.children,void 0,void 0,(l=(u=t.children)?u.length:0)>=(f=c?c.length:0)?l:f);d++)e(o,t.children[d],r.children[d],d);var u,c,l,f}(e,o,d)}()}function c(e,n){if((e="function"==typeof e?e(n):e).children)for(var t=0;t<e.children.length;t++)e.children[t]=c(e.children[t],n);return e}function a(e,n){void 0===n&&(n={});var t=n.mount;void 0===t&&(t=!0);var r=n.initial;void 0===r&&(r=!1);var i=typeof e;if("string"===i||"number"===i)return document.createTextNode(e);if("boolean"===i)return document.createTextNode("");for(var d=document.createElement(e.element),u=0,c=Object.entries(e);u<c.length;u+=1){var v=c[u],f=v[0],s=v[1];if("events"===f&&p(s,d,t,r),["children","element","events"].includes(f)||d.setAttribute(f,s),"children"===f)for(var h=0;h<s.length;h++)d.appendChild(a(s[h],{mount:t,initial:r}))}return d;function p(e,n,t,r){for(var i=0,d=Object.entries(e);i<d.length;i+=1){var u=d[i],c=u[0],a=u[1];["mounted","unmounted","updated"].includes(c)||n.addEventListener(c,a),v(c,a,t,r)}function v(e,n,t,r){r&&(t&&"mounted"===e&&o.push(n),t||"updated"!==e||o.push(n),l())}}}function v(e,n){if(e.events){for(var t=0,r=Object.entries(e.events);t<r.length;t+=1){var i=r[t];i[0]===n&&o.push(i[1])}l()}}function l(){var e=new Event("__LITERAL_LIFECYCLE__");return window.dispatchEvent(e)}module.exports={component:function(e){void 0===e&&(e={});var n=e.methods;void 0===n&&(n=function(){});var t=e.render;return void 0===t&&(t=function(){}),function(e){return void 0===e&&(e={}),function(r){return t({state:d(r),getState:d,setState:u,props:e,methods:n({getState:d,setState:u})})}}},render:function(i,d,u){void 0===u&&(u={}),r=Object.assign({},r,u),e=document.getElementById(d),n=i;var v=c(i(),r);function l(){for(var e;e=o.pop();)e()}t=Object.assign({},v),e.appendChild(a(v,{initial:!0})),l(),window.addEventListener("__LITERAL_LIFECYCLE__",l)},h:function(e,n){for(var t=[],r=arguments.length-2;r-- >0;)t[r]=arguments[r+2];return"function"==typeof e?e:Object.assign({},{element:e},n,{children:function e(n,t){for(var r=0;r<n.length;r++)Array.isArray(n[r])?e(n[r],t):t.push(n[r]);return t}(t,[])})}}; | ||
var e,n,t,i={},r=[];function o(e){if((e="function"==typeof e?new e:e).children)for(var n=0;n<e.children.length;n++)e.children[n]=o(e.children[n]);return e}function d(e,n){void 0===n&&(n={});var t=n.mount;void 0===t&&(t=!0);var i=n.initial;void 0===i&&(i=!1);var o=typeof e;if("string"===o||"number"===o)return document.createTextNode(e);if("boolean"===o)return document.createTextNode("");for(var c=document.createElement(e.element),a=0,s=Object.entries(e);a<s.length;a+=1){var l=s[a],v=l[0],f=l[1];if("events"===v&&m(f,c,t,i),["children","element","events"].includes(v)||c.setAttribute(v,f),"children"===v)for(var h=0;h<f.length;h++)c.appendChild(d(f[h],{mount:t,initial:i}))}return c;function m(e,n,t,i){for(var o=0,d=Object.entries(e);o<d.length;o+=1){var c=d[o],a=c[0],s=c[1];["mounted","unmounted","updated"].includes(a)||n.addEventListener(a,s),l(a,s,t,i)}function l(e,n,t,i){i&&(t&&"mounted"===e&&r.push(n),t||"updated"!==e||r.push(n),u())}}}function u(){var e=new Event("__LITERAL_LIFECYCLE__");return window.dispatchEvent(e)}module.exports={component:function(c){void 0===c&&(c={});var a=c.methods;void 0===a&&(a=function(){});var s=c.render;return void 0===s&&(s=function(){}),function(c){return void 0===c&&(c={}),function(l){for(var v in void 0===l&&(l={}),s=s.bind(this),"function"==typeof a&&(a=a.bind(this)()),a)this[v]=a[v].bind(this);return this.getState=function(){return Object.assign({},i,l)},this.setState=function(c){var a,s,l=Object.assign({},this.getState(),c);i=l,a=o(n()),s=Object.assign({},t),t=Object.assign({},a),function e(n,t,i,o){if(void 0===o&&(o=0),n){var c,a,s,l,v=typeof t,f=typeof i,h=n.childNodes[o];if(void 0===i)return n.appendChild(d(t)),void p(t,"mounted");if(void 0===t)return n.removeChild(h),void p(i,"unmounted");if(!1===i&&(t.element||"string"===v||"number"===v))return n.replaceChild(d(t),h),void p(t,"mounted");if(!1===t&&(i.element||"string"===f||"number"===f))return n.replaceChild(d(t),h),void p(i,"unmounted");if(function(e,n,t,i){return t!==i||"string"===t&&e!==n||e.element!==n.element}(t,i,v,f))return n.replaceChild(d(t,{mount:!1}),h),void p(t,"mounted");if(t.element&&(function(e,n,t,i){for(var r=0,o=Object.entries(t);r<o.length;r+=1){var d=o[r],u=d[0],c=d[1],a=i[u];["children","events"].includes(u)||a&&c===a||(n.setAttribute(u,c),p(t,"updated"))}}(0,h,t,i),t.children||i.children))for(var m=0;m<(a=i.children,(s=(c=t.children)?c.length:0)>=(l=a?a.length:0)?s:l);m++)e(h,t.children[m],i.children[m],m)}function p(e,n){if(e.events){for(var t=0,i=Object.entries(e.events);t<i.length;t+=1){var o=i[t],d=o[0],c=o[1];d===n&&r.push(c)}u()}}}(e,a,s)}.bind(this),this.props=c,s()}}},render:function(u,c,a){void 0===a&&(a={}),i=Object.assign({},i,a),e=document.getElementById(c),n=u;var s=o(u());function l(){for(var e;e=r.pop();)e()}t=Object.assign({},s),e.appendChild(d(s,{initial:!0})),l(),window.addEventListener("__LITERAL_LIFECYCLE__",l)},h:function(e,n){for(var t=[],i=arguments.length-2;i-- >0;)t[i]=arguments[i+2];return Object.assign({},{element:e},n,{children:function e(n,t){for(var i=0;i<n.length;i++)Array.isArray(n[i])?e(n[i],t):t.push(n[i]);return t}(t,[])})}}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
var e,n,t,r={},i=[],o=[],d=function(e,n){for(var t=[],r=arguments.length-2;r-- >0;)t[r]=arguments[r+2];return"function"==typeof e?e:Object.assign({},{element:e},n,{children:function e(n,t){for(var r=0;r<n.length;r++)Array.isArray(n[r])?e(n[r],t):t.push(n[r]);return t}(t,[])})},u=function(i,d,u){void 0===u&&(u={}),r=Object.assign({},r,u),e=document.getElementById(d),n=i;var c=f(i(),r);function a(){for(var e;e=o.pop();)e()}t=Object.assign({},c),e.appendChild(l(c,{initial:!0})),a(),window.addEventListener("__LITERAL_LIFECYCLE__",a)},c=function(e){void 0===e&&(e={});var n=e.methods;void 0===n&&(n=function(){});var t=e.render;return void 0===t&&(t=function(){}),function(e){return void 0===e&&(e={}),function(r){return t({state:a(r),getState:a,setState:v,props:e,methods:n({getState:a,setState:v})})}}};function a(e){return void 0===e&&(e=r),Object.assign({},e)}function v(o){var d=Object.assign({},a(),o);r=d,i.push(d),function(){var r=i.pop(),o=f(n(),r),d=Object.assign({},t);t=Object.assign({},o),function e(n,t,r,i){void 0===i&&(i=0);if(!n)return;var o=n.childNodes[i];if(void 0===r)return n.appendChild(l(t)),void s(t,"mounted");if(!1===r)return n.replaceChild(l(t),o),void s(t,"mounted");if(!1===t)return n.replaceChild(l(t),o),void s(r,"unmounted");if(void 0===t)return n.removeChild(o),void s(r,"unmounted");if(function(e,n){var t=typeof e;return t!==typeof n||"string"===t&&e!==n||e.element!==n.element}(t,r))return n.replaceChild(l(t,{mount:!1}),o),void s(t,"mounted");if(t.element&&(function(e,n,t,r){for(var i=0,o=Object.entries(t);i<o.length;i+=1){var d=o[i],u=d[0],c=d[1],a=r[u];["children","events"].includes(u)||a&&c===a||(n.setAttribute(u,c),s(t,"updated"))}}(0,o,t,r),t.children||r.children))for(var d=0;d<(c=r.children,void 0,void 0,(a=(u=t.children)?u.length:0)>=(v=c?c.length:0)?a:v);d++)e(o,t.children[d],r.children[d],d);var u,c,a,v}(e,o,d)}()}function f(e,n){if((e="function"==typeof e?e(n):e).children)for(var t=0;t<e.children.length;t++)e.children[t]=f(e.children[t],n);return e}function l(e,n){void 0===n&&(n={});var t=n.mount;void 0===t&&(t=!0);var r=n.initial;void 0===r&&(r=!1);var i=typeof e;if("string"===i||"number"===i)return document.createTextNode(e);if("boolean"===i)return document.createTextNode("");for(var d=document.createElement(e.element),u=0,c=Object.entries(e);u<c.length;u+=1){var a=c[u],v=a[0],f=a[1];if("events"===v&&p(f,d,t,r),["children","element","events"].includes(v)||d.setAttribute(v,f),"children"===v)for(var s=0;s<f.length;s++)d.appendChild(l(f[s],{mount:t,initial:r}))}return d;function p(e,n,t,r){for(var i=0,d=Object.entries(e);i<d.length;i+=1){var u=d[i],c=u[0],a=u[1];["mounted","unmounted","updated"].includes(c)||n.addEventListener(c,a),v(c,a,t,r)}function v(e,n,t,r){r&&(t&&"mounted"===e&&o.push(n),t||"updated"!==e||o.push(n),h())}}}function s(e,n){if(e.events){for(var t=0,r=Object.entries(e.events);t<r.length;t+=1){var i=r[t];i[0]===n&&o.push(i[1])}h()}}function h(){var e=new Event("__LITERAL_LIFECYCLE__");return window.dispatchEvent(e)}export default{component:c,render:u,h:d};export{d as h,u as render,c as component}; | ||
var e,n,t,i={},r=[],o=function(e,n){for(var t=[],i=arguments.length-2;i-- >0;)t[i]=arguments[i+2];return Object.assign({},{element:e},n,{children:function e(n,t){for(var i=0;i<n.length;i++)Array.isArray(n[i])?e(n[i],t):t.push(n[i]);return t}(t,[])})},d=function(o,d,u){void 0===u&&(u={}),i=Object.assign({},i,u),e=document.getElementById(d),n=o;var l=c(o());function s(){for(var e;e=r.pop();)e()}t=Object.assign({},l),e.appendChild(a(l,{initial:!0})),s(),window.addEventListener("__LITERAL_LIFECYCLE__",s)},u=function(o){void 0===o&&(o={});var d=o.methods;void 0===d&&(d=function(){});var u=o.render;return void 0===u&&(u=function(){}),function(o){return void 0===o&&(o={}),function(s){for(var v in void 0===s&&(s={}),u=u.bind(this),"function"==typeof d&&(d=d.bind(this)()),d)this[v]=d[v].bind(this);return this.getState=function(){return Object.assign({},i,s)},this.setState=function(o){var d,u,s=Object.assign({},this.getState(),o);i=s,d=c(n()),u=Object.assign({},t),t=Object.assign({},d),function e(n,t,i,o){if(void 0===o&&(o=0),n){var d,u,c,s,v=typeof t,f=typeof i,h=n.childNodes[o];if(void 0===i)return n.appendChild(a(t)),void p(t,"mounted");if(void 0===t)return n.removeChild(h),void p(i,"unmounted");if(!1===i&&(t.element||"string"===v||"number"===v))return n.replaceChild(a(t),h),void p(t,"mounted");if(!1===t&&(i.element||"string"===f||"number"===f))return n.replaceChild(a(t),h),void p(i,"unmounted");if(function(e,n,t,i){return t!==i||"string"===t&&e!==n||e.element!==n.element}(t,i,v,f))return n.replaceChild(a(t,{mount:!1}),h),void p(t,"mounted");if(t.element&&(function(e,n,t,i){for(var r=0,o=Object.entries(t);r<o.length;r+=1){var d=o[r],u=d[0],c=d[1],a=i[u];["children","events"].includes(u)||a&&c===a||(n.setAttribute(u,c),p(t,"updated"))}}(0,h,t,i),t.children||i.children))for(var m=0;m<(u=i.children,(c=(d=t.children)?d.length:0)>=(s=u?u.length:0)?c:s);m++)e(h,t.children[m],i.children[m],m)}function p(e,n){if(e.events){for(var t=0,i=Object.entries(e.events);t<i.length;t+=1){var o=i[t],d=o[0],u=o[1];d===n&&r.push(u)}l()}}}(e,d,u)}.bind(this),this.props=o,u()}}};function c(e){if((e="function"==typeof e?new e:e).children)for(var n=0;n<e.children.length;n++)e.children[n]=c(e.children[n]);return e}function a(e,n){void 0===n&&(n={});var t=n.mount;void 0===t&&(t=!0);var i=n.initial;void 0===i&&(i=!1);var o=typeof e;if("string"===o||"number"===o)return document.createTextNode(e);if("boolean"===o)return document.createTextNode("");for(var d=document.createElement(e.element),u=0,c=Object.entries(e);u<c.length;u+=1){var s=c[u],v=s[0],f=s[1];if("events"===v&&m(f,d,t,i),["children","element","events"].includes(v)||d.setAttribute(v,f),"children"===v)for(var h=0;h<f.length;h++)d.appendChild(a(f[h],{mount:t,initial:i}))}return d;function m(e,n,t,i){for(var o=0,d=Object.entries(e);o<d.length;o+=1){var u=d[o],c=u[0],a=u[1];["mounted","unmounted","updated"].includes(c)||n.addEventListener(c,a),s(c,a,t,i)}function s(e,n,t,i){i&&(t&&"mounted"===e&&r.push(n),t||"updated"!==e||r.push(n),l())}}}function l(){var e=new Event("__LITERAL_LIFECYCLE__");return window.dispatchEvent(e)}export default{component:u,render:d,h:o};export{o as h,d as render,u as component}; | ||
//# sourceMappingURL=index.m.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):e.literaljs=n()}(this,function(){var e,n,t,r={},i=[],o=[];function d(e){return void 0===e&&(e=r),Object.assign({},e)}function u(o){var u=Object.assign({},d(),o);r=u,i.push(u),function(){var r=i.pop(),o=c(n(),r),d=Object.assign({},t);t=Object.assign({},o),function e(n,t,r,i){void 0===i&&(i=0);if(!n)return;var o=n.childNodes[i];if(void 0===r)return n.appendChild(a(t)),void f(t,"mounted");if(!1===r)return n.replaceChild(a(t),o),void f(t,"mounted");if(!1===t)return n.replaceChild(a(t),o),void f(r,"unmounted");if(void 0===t)return n.removeChild(o),void f(r,"unmounted");if(function(e,n){var t=typeof e;return t!==typeof n||"string"===t&&e!==n||e.element!==n.element}(t,r))return n.replaceChild(a(t,{mount:!1}),o),void f(t,"mounted");if(t.element&&(function(e,n,t,r){for(var i=0,o=Object.entries(t);i<o.length;i+=1){var d=o[i],u=d[0],c=d[1],a=r[u];["children","events"].includes(u)||a&&c===a||(n.setAttribute(u,c),f(t,"updated"))}}(0,o,t,r),t.children||r.children))for(var d=0;d<(c=r.children,void 0,void 0,(v=(u=t.children)?u.length:0)>=(l=c?c.length:0)?v:l);d++)e(o,t.children[d],r.children[d],d);var u,c,v,l}(e,o,d)}()}function c(e,n){if((e="function"==typeof e?e(n):e).children)for(var t=0;t<e.children.length;t++)e.children[t]=c(e.children[t],n);return e}function a(e,n){void 0===n&&(n={});var t=n.mount;void 0===t&&(t=!0);var r=n.initial;void 0===r&&(r=!1);var i=typeof e;if("string"===i||"number"===i)return document.createTextNode(e);if("boolean"===i)return document.createTextNode("");for(var d=document.createElement(e.element),u=0,c=Object.entries(e);u<c.length;u+=1){var f=c[u],l=f[0],s=f[1];if("events"===l&&p(s,d,t,r),["children","element","events"].includes(l)||d.setAttribute(l,s),"children"===l)for(var h=0;h<s.length;h++)d.appendChild(a(s[h],{mount:t,initial:r}))}return d;function p(e,n,t,r){for(var i=0,d=Object.entries(e);i<d.length;i+=1){var u=d[i],c=u[0],a=u[1];["mounted","unmounted","updated"].includes(c)||n.addEventListener(c,a),f(c,a,t,r)}function f(e,n,t,r){r&&(t&&"mounted"===e&&o.push(n),t||"updated"!==e||o.push(n),v())}}}function f(e,n){if(e.events){for(var t=0,r=Object.entries(e.events);t<r.length;t+=1){var i=r[t];i[0]===n&&o.push(i[1])}v()}}function v(){var e=new Event("__LITERAL_LIFECYCLE__");return window.dispatchEvent(e)}return{component:function(e){void 0===e&&(e={});var n=e.methods;void 0===n&&(n=function(){});var t=e.render;return void 0===t&&(t=function(){}),function(e){return void 0===e&&(e={}),function(r){return t({state:d(r),getState:d,setState:u,props:e,methods:n({getState:d,setState:u})})}}},render:function(i,d,u){void 0===u&&(u={}),r=Object.assign({},r,u),e=document.getElementById(d),n=i;var f=c(i(),r);function v(){for(var e;e=o.pop();)e()}t=Object.assign({},f),e.appendChild(a(f,{initial:!0})),v(),window.addEventListener("__LITERAL_LIFECYCLE__",v)},h:function(e,n){for(var t=[],r=arguments.length-2;r-- >0;)t[r]=arguments[r+2];return"function"==typeof e?e:Object.assign({},{element:e},n,{children:function e(n,t){for(var r=0;r<n.length;r++)Array.isArray(n[r])?e(n[r],t):t.push(n[r]);return t}(t,[])})}}}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):e.literaljs=n()}(this,function(){var e,n,t,i={},r=[];function o(e){if((e="function"==typeof e?new e:e).children)for(var n=0;n<e.children.length;n++)e.children[n]=o(e.children[n]);return e}function d(e,n){void 0===n&&(n={});var t=n.mount;void 0===t&&(t=!0);var i=n.initial;void 0===i&&(i=!1);var o=typeof e;if("string"===o||"number"===o)return document.createTextNode(e);if("boolean"===o)return document.createTextNode("");for(var c=document.createElement(e.element),f=0,a=Object.entries(e);f<a.length;f+=1){var s=a[f],l=s[0],v=s[1];if("events"===l&&m(v,c,t,i),["children","element","events"].includes(l)||c.setAttribute(l,v),"children"===l)for(var h=0;h<v.length;h++)c.appendChild(d(v[h],{mount:t,initial:i}))}return c;function m(e,n,t,i){for(var o=0,d=Object.entries(e);o<d.length;o+=1){var c=d[o],f=c[0],a=c[1];["mounted","unmounted","updated"].includes(f)||n.addEventListener(f,a),s(f,a,t,i)}function s(e,n,t,i){i&&(t&&"mounted"===e&&r.push(n),t||"updated"!==e||r.push(n),u())}}}function u(){var e=new Event("__LITERAL_LIFECYCLE__");return window.dispatchEvent(e)}return{component:function(c){void 0===c&&(c={});var f=c.methods;void 0===f&&(f=function(){});var a=c.render;return void 0===a&&(a=function(){}),function(c){return void 0===c&&(c={}),function(s){for(var l in void 0===s&&(s={}),a=a.bind(this),"function"==typeof f&&(f=f.bind(this)()),f)this[l]=f[l].bind(this);return this.getState=function(){return Object.assign({},i,s)},this.setState=function(c){var f,a,s=Object.assign({},this.getState(),c);i=s,f=o(n()),a=Object.assign({},t),t=Object.assign({},f),function e(n,t,i,o){if(void 0===o&&(o=0),n){var c,f,a,s,l=typeof t,v=typeof i,h=n.childNodes[o];if(void 0===i)return n.appendChild(d(t)),void p(t,"mounted");if(void 0===t)return n.removeChild(h),void p(i,"unmounted");if(!1===i&&(t.element||"string"===l||"number"===l))return n.replaceChild(d(t),h),void p(t,"mounted");if(!1===t&&(i.element||"string"===v||"number"===v))return n.replaceChild(d(t),h),void p(i,"unmounted");if(function(e,n,t,i){return t!==i||"string"===t&&e!==n||e.element!==n.element}(t,i,l,v))return n.replaceChild(d(t,{mount:!1}),h),void p(t,"mounted");if(t.element&&(function(e,n,t,i){for(var r=0,o=Object.entries(t);r<o.length;r+=1){var d=o[r],u=d[0],c=d[1],f=i[u];["children","events"].includes(u)||f&&c===f||(n.setAttribute(u,c),p(t,"updated"))}}(0,h,t,i),t.children||i.children))for(var m=0;m<(f=i.children,(a=(c=t.children)?c.length:0)>=(s=f?f.length:0)?a:s);m++)e(h,t.children[m],i.children[m],m)}function p(e,n){if(e.events){for(var t=0,i=Object.entries(e.events);t<i.length;t+=1){var o=i[t],d=o[0],c=o[1];d===n&&r.push(c)}u()}}}(e,f,a)}.bind(this),this.props=c,a()}}},render:function(u,c,f){void 0===f&&(f={}),i=Object.assign({},i,f),e=document.getElementById(c),n=u;var a=o(u());function s(){for(var e;e=r.pop();)e()}t=Object.assign({},a),e.appendChild(d(a,{initial:!0})),s(),window.addEventListener("__LITERAL_LIFECYCLE__",s)},h:function(e,n){for(var t=[],i=arguments.length-2;i-- >0;)t[i]=arguments[i+2];return Object.assign({},{element:e},n,{children:function e(n,t){for(var i=0;i<n.length;i++)Array.isArray(n[i])?e(n[i],t):t.push(n[i]);return t}(t,[])})}}}); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "literaljs", | ||
"version": "2.5.1", | ||
"version": "3.0.0", | ||
"description": "~1kb JavaScript library for building user interfaces.", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -15,5 +15,5 @@ <p align="center"> | ||
Build output to build: | ||
1.28 kB: index.js | ||
1.29 kB: index.m.js | ||
1.33 kB: index.umd.js | ||
1.3 kB: index.js | ||
1.31 kB: index.m.js | ||
1.36 kB: index.umd.js | ||
``` | ||
@@ -20,0 +20,0 @@ ### [Features and stuff](#features) |
import { component, h } from '../src'; | ||
describe('Component Tests', () => { | ||
test('Component Object Syntax Works', () => { | ||
expect( | ||
component({ | ||
render: () => ({ | ||
element: 'div', | ||
children: [ | ||
{ | ||
element: 'span', | ||
text: 'Hello World' | ||
} | ||
] | ||
}) | ||
})()() | ||
).toEqual({ | ||
element: 'div', | ||
children: [ | ||
{ | ||
element: 'span', | ||
text: 'Hello World' | ||
} | ||
] | ||
}); | ||
}); | ||
test('Component H Syntax Works', () => { | ||
const Comp = new component({ | ||
render() { | ||
return h('div', {}, h('span', {}, 'Hello World')); | ||
} | ||
})(); | ||
test('Component H Syntax Works', () => { | ||
expect( | ||
component({ | ||
render: () => h('div', {}, h('span', { text: 'Hello World' })) | ||
})()() | ||
).toEqual({ | ||
expect(new Comp()).toEqual({ | ||
element: 'div', | ||
@@ -38,4 +16,3 @@ children: [ | ||
element: 'span', | ||
text: 'Hello World', | ||
children: [] | ||
children: ['Hello World'] | ||
} | ||
@@ -48,8 +25,9 @@ ] | ||
const count = 1; | ||
expect( | ||
component({ | ||
render: ({ props: { count } }) => | ||
h('div', {}, h('span', { text: `${count}` })) | ||
})({ count: count })() | ||
).toEqual({ | ||
const Comp = new component({ | ||
render() { | ||
return h('div', {}, h('span', {}, this.props.count)); | ||
} | ||
})({ count: count }); | ||
expect(new Comp()).toEqual({ | ||
element: 'div', | ||
@@ -59,4 +37,3 @@ children: [ | ||
element: 'span', | ||
text: `${count}`, | ||
children: [] | ||
children: [count] | ||
} | ||
@@ -69,8 +46,9 @@ ] | ||
const count = 1; | ||
expect( | ||
component({ | ||
render: ({ state }) => | ||
h('div', {}, h('span', { text: `${state.count}` })) | ||
})()({ count: count }) | ||
).toEqual({ | ||
const Comp = component({ | ||
render() { | ||
return h('div', {}, h('span', {}, this.getState().count)); | ||
} | ||
})(); | ||
expect(new Comp({ count })).toEqual({ | ||
element: 'div', | ||
@@ -80,4 +58,3 @@ children: [ | ||
element: 'span', | ||
text: `${count}`, | ||
children: [] | ||
children: [count] | ||
} | ||
@@ -90,11 +67,15 @@ ] | ||
const count = 1; | ||
expect( | ||
component({ | ||
methods: () => ({ | ||
count: () => count | ||
}), | ||
render: ({ methods: { count } }) => | ||
h('div', {}, h('span', { text: `${count()}` })) | ||
})()() | ||
).toEqual({ | ||
const Comp = component({ | ||
methods() { | ||
return { | ||
count() { | ||
return count; | ||
} | ||
}; | ||
}, | ||
render() { | ||
return h('div', {}, h('span', {}, this.count())); | ||
} | ||
})(); | ||
expect(new Comp()).toEqual({ | ||
element: 'div', | ||
@@ -104,4 +85,3 @@ children: [ | ||
element: 'span', | ||
text: `${count}`, | ||
children: [] | ||
children: [count] | ||
} | ||
@@ -108,0 +88,0 @@ ] |
@@ -10,4 +10,4 @@ import { render, component, h } from '../src'; | ||
const Comp2 = component({ | ||
render: ({ state, getState, setState }) => | ||
h( | ||
render() { | ||
return h( | ||
'button', | ||
@@ -17,6 +17,6 @@ { | ||
events: { | ||
click: () => setState({ show: !getState().show }) | ||
click: () => this.setState({ show: !this.getState().show }) | ||
} | ||
}, | ||
state.show && | ||
this.getState().show && | ||
h( | ||
@@ -27,4 +27,4 @@ 'span', | ||
mounted: () => { | ||
setState({ count: getState().count + 1 }); | ||
expect(getState().count).toBe(2); | ||
this.setState({ count: this.getState().count + 1 }); | ||
expect(this.getState().count).toBe(2); | ||
done(); | ||
@@ -34,9 +34,12 @@ } | ||
}, | ||
state.count | ||
this.getState().count | ||
) | ||
) | ||
); | ||
} | ||
}); | ||
const Comp = component({ | ||
render: ({ state }) => h('div', { class: 'container' }, Comp2()) | ||
render() { | ||
return h('div', { class: 'container' }, Comp2()); | ||
} | ||
}); | ||
@@ -49,34 +52,37 @@ | ||
// test('Lifecycle unmounted works with getState and setState', () => { | ||
// const Comp2 = component({ | ||
// render: ({ state, getState, setState }) => | ||
// h( | ||
// 'button', | ||
// { | ||
// id: 'button', | ||
// events: { | ||
// mounted: () => setState({ show: !getState().show }) | ||
// } | ||
// }, | ||
// state.show && | ||
// h('span', { | ||
// events: { | ||
// unmounted: () => { | ||
// setState({ count: getState().count + 1 }); | ||
// } | ||
// } | ||
// }), | ||
// h('span', { id: 'count' }, state.count) | ||
// ) | ||
// }); | ||
test('Lifecycle unmounted works with getState and setState', done => { | ||
const Comp2 = component({ | ||
render() { | ||
return h( | ||
'button', | ||
{ | ||
id: 'button', | ||
events: { | ||
mounted: () => | ||
setTimeout(() => this.setState({ show: !this.getState().show })) | ||
} | ||
}, | ||
this.getState().show && | ||
h('span', { | ||
events: { | ||
unmounted: () => { | ||
this.setState({ count: this.getState().count + 1 }); | ||
expect(this.getState().count).toBe(2); | ||
done(); | ||
} | ||
} | ||
}), | ||
h('span', { id: 'count' }, this.getState().count) | ||
); | ||
} | ||
}); | ||
// const Comp = component({ | ||
// render: ({ state }) => h('div', { class: 'container' }, Comp2()) | ||
// }); | ||
const Comp = component({ | ||
render: () => h('div', { class: 'container' }, Comp2()) | ||
}); | ||
// render(Comp, 'root', { show: true, count: 1 }); | ||
render(Comp, 'root', { show: true, count: 1 }); | ||
// document.getElementById('button').click(); | ||
// expect(document.getElementById('count').innerHTML).toBe('2'); | ||
// }); | ||
document.getElementById('button').click(); | ||
}); | ||
}); |
@@ -10,3 +10,5 @@ import { render, component, h } from '../src'; | ||
const Comp = component({ | ||
render: () => h('span', { class: 'container' }, 'Hello World') | ||
render() { | ||
return h('span', { class: 'container' }, 'Hello World'); | ||
} | ||
}); | ||
@@ -23,3 +25,5 @@ | ||
const Comp = component({ | ||
render: ({ state }) => h('span', { class: 'container' }, state.count) | ||
render() { | ||
return h('span', { class: 'container' }, this.getState().count); | ||
} | ||
}); | ||
@@ -36,6 +40,10 @@ | ||
const Comp2 = component({ | ||
render: ({ state }) => h('span', {}, state.count) | ||
render() { | ||
return h('span', {}, this.getState().count); | ||
} | ||
}); | ||
const Comp = component({ | ||
render: () => h('div', { class: 'container' }, Comp2()) | ||
render() { | ||
return h('div', { class: 'container' }, Comp2()); | ||
} | ||
}); | ||
@@ -52,6 +60,7 @@ | ||
const Comp = component({ | ||
render: ({ state }) => | ||
h('div', { class: 'container' }, [ | ||
state.show && h('span', {}, 'Hello World') | ||
]) | ||
render() { | ||
return h('div', { class: 'container' }, [ | ||
this.getState().show && h('span', {}, 'Hello World') | ||
]); | ||
} | ||
}); | ||
@@ -68,6 +77,7 @@ | ||
const Comp = component({ | ||
render: ({ state }) => | ||
h('div', { class: 'container' }, [ | ||
state.show && h('span', { id: 'hello' }, 'Hello World') | ||
]) | ||
render() { | ||
return h('div', { class: 'container' }, [ | ||
this.getState().show && h('span', { id: 'hello' }, 'Hello World') | ||
]); | ||
} | ||
}); | ||
@@ -82,7 +92,11 @@ | ||
const Comp2 = component({ | ||
methods: ({ getState, setState }) => ({ | ||
increment: () => setState({ count: getState().count + 1 }) | ||
}), | ||
render: ({ state, getState, methods: { increment } }) => | ||
h( | ||
methods() { | ||
return { | ||
increment() { | ||
this.setState({ count: this.getState().count + 1 }); | ||
} | ||
}; | ||
}, | ||
render() { | ||
return h( | ||
'button', | ||
@@ -93,4 +107,4 @@ { | ||
click: () => { | ||
increment(); | ||
expect(getState().count).toBe(2); | ||
this.increment(); | ||
expect(this.getState().count).toBe(2); | ||
done(); | ||
@@ -101,7 +115,10 @@ } | ||
'Click Me' | ||
) | ||
); | ||
} | ||
}); | ||
const Comp = component({ | ||
render: ({ state }) => h('div', { class: 'container' }, Comp2()) | ||
render() { | ||
return h('div', { class: 'container' }, Comp2()); | ||
} | ||
}); | ||
@@ -116,4 +133,4 @@ | ||
const Comp2 = component({ | ||
render: ({ state, setState, getState }) => | ||
h( | ||
render() { | ||
return h( | ||
'button', | ||
@@ -124,4 +141,4 @@ { | ||
click: () => { | ||
setState({ count: getState().count + 1 }); | ||
expect(getState().count).toBe(2); | ||
this.setState({ count: this.getState().count + 1 }); | ||
expect(this.getState().count).toBe(2); | ||
done(); | ||
@@ -132,7 +149,10 @@ } | ||
'Click Me' | ||
) | ||
); | ||
} | ||
}); | ||
const Comp = component({ | ||
render: ({ state }) => h('div', { class: 'container' }, Comp2()) | ||
render() { | ||
return h('div', { class: 'container' }, Comp2()); | ||
} | ||
}); | ||
@@ -139,0 +159,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
367177
486