Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

literaljs

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

literaljs - npm Package Compare versions

Comparing version 5.0.2 to 5.1.0

2

build/index.js

@@ -1,2 +0,2 @@

var e,t,n,i={},r={},u="luid",d="euid",o=[],a=[],s={},f=[];function c(e){var t;if(void 0!==e){if("function"==typeof e.render)t=e.uuid,(e=new e.render).uuid=t,e.attributes&&(e.attributes["data-"+u]=t);else if("function"==typeof e.element){var n=Object.assign({},e.attributes.props)||{};delete e.attributes.props,(e=e.element(n)).render&&(t=e.uuid,(e=new e.render).uuid=t,e.attributes&&(e.attributes["data-"+u]=t))}if(e.children)for(var i=0;i<e.children.length;i++)e.children[i]=c(e.children[i]);return e}}function l(e,t){void 0===t&&(t={});var n=t.mount;void 0===n&&(n=!0);var i=t.initial;void 0===i&&(i=!1);var r=typeof e;if("undefined"===r)return!1;if("string"===r||"number"===r)return document.createTextNode(e);if("boolean"===r)return document.createTextNode("");var u=document.createElement(e.element);if(e.attributes&&"object"==typeof e.attributes)for(var d=0,o=Object.entries(e.attributes);d<o.length;d+=1){var a=o[d],s=a[0],f=a[1];"events"===s?(v(f,u),b(f,n,i)):"style"===s?h(f,u):u.setAttribute(s,f)}if(e.children&&e.children.length)for(var c=0;c<e.children.length;c++)u.appendChild(l(e.children[c],{mount:n,initial:i}));return u}function v(t,n){if(n){!function(t){for(var n=Object.keys(t),i=0;i<n.length;i++)["mounted","updated","unmounted"].includes(n[i])||o.push(n[i]);!function(){var t;for(;t=o.pop();)a.includes(t)||(a.push(t),e.addEventListener(t,function(e){var t=e.target.getAttribute("data-"+d);if(t&&s[t]){var n=e.type,i=s[t][n];i&&i(e)}}))}()}(t);var i=y();n.setAttribute("data-"+d,i),s[i]=t}}function h(e,t){if(e&&"object"==typeof e)for(var n=0,i=Object.entries(e);n<i.length;n+=1){var r=i[n];t.style[r[0]]=r[1]}}function b(e,t,n){for(var i=0,r=Object.entries(e);i<r.length;i+=1){var u=r[i];d(u[0],u[1],t,n)}function d(e,t,n,i){i&&(n&&"mounted"===e&&f.push(t),n||"updated"!==e||f.push(t),m())}}function g(i){var r=c(t()),d=Object.assign({},n);n=Object.assign({},r);var o=e,a=e;if(!i)return p(o,r,d);o=document.querySelector("[data-"+u+'="'+i+'"]'),a=o.parentNode;var s=!1,f=function(e,t,n,i){if(!s){if(!e)return{newTree:void 0,oldTree:void 0};if(e.uuid&&e.uuid===n)return{newTree:e,oldTree:t};if(e.children)for(var r=e.children.length,u=0;u<r;u++){var d=e.children[u],o=t.children[u];d.uuid&&d.uuid===n?i(s={newTree:d,oldTree:o}):f(d,o,n,i)}}};f(r,d,i,function(e){for(var t=0;t<a.children.length;t++){var n=a.children[t].dataset[u];if(n&&n===i)return p(a,e.newTree,e.oldTree,t)}})}function p(e,t,n,i){if(void 0===i&&(i=0),e){var r=typeof t,u=typeof n,o=e.childNodes[i];if("undefined"===u)e.appendChild(l(t)),O(t,"mounted");else if("undefined"===r)j(o),e.removeChild(o),O(n,"unmounted");else if(!1!==n||!t.element&&"string"!==r&&"number"!==r)if(!1!==t||!n.element&&"string"!==u&&"number"!==u){if(function(e,t,n,i){return n!==i||"string"===n&&e!==t||e.element!==t.element}(t,n,r,u))j(o),e.replaceChild(l(t,{mount:!1}),o),O(n,"unmounted"),O(t,"mounted");else if(t.element){!function(e,t,n){for(var i=0,r=Object.entries(t.attributes);i<r.length;i+=1){var u=r[i],d=u[0],o=u[1],a=n.attributes?n.attributes[d]:void 0;if("style"===d){if(void 0,void 0,l=typeof(f=a),"object"===(c=typeof(s=o))&&"object"===l&&JSON.stringify(s)===JSON.stringify(f)||"undefined"===c&&"undefined"===l)return;e.removeAttribute("style"),h(o,e)}else"events"===d?(j(e),v(o,e)):"value"===d&&o!==a?e.value=o:a&&o===a||e.setAttribute(d,o)}var s,f,c,l}(o,t,n),O(t,"updated");var a=t.children?t.children.length:0,c=o.childNodes.length;if(a<c)for(var b=c-1;b>0;b--)if(void 0===t.children[b]){var g=o.lastChild;j(g),g.remove(),O(n.children[b],"unmounted")}for(var y=0;y<a;y++)p(o,t.children[y],n.children[y],y)}}else j(o),e.replaceChild(l(t),o),O(n,"unmounted"),O(t,"mounted");else j(o),e.replaceChild(l(t),o),O(n,"unmounted"),O(t,"mounted")}function j(e){if(e&&e.getAttribute){var t=e.getAttribute("data-"+d);t&&delete s[t]}}function O(e,t){if(e&&e.attributes&&e.attributes.events){for(var n=0,i=Object.entries(e.attributes.events);n<i.length;n+=1){var r=i[n];r[0]===t&&f.push(r[1])}m()}}}function m(){var e=new Event("__LITERAL_LIFECYCLE__");return window.dispatchEvent(e)}function y(){return Math.random().toString(36).substring(2)+(new Date).getTime().toString(36)}module.exports={component:function(e){void 0===e&&(e={});var t=e.state;void 0===t&&(t={});var n=e.methods;void 0===n&&(n=function(){});var u=e.render;void 0===u&&(u=function(){});var d=y();return r[d]=t,function(e){return void 0===e&&(e={}),{uuid:d,render:function(){for(var t in this.uuid=d,this.props=e,this.getState=function(){return Object.assign({},r[this.uuid])}.bind(this),this.setState=function(e){var t=Object.assign({},this.getState(),e);r[this.uuid]=t,g(this.uuid)}.bind(this),this.getStore=function(){return Object.assign({},i)},this.setStore=function(e){var t=Object.assign({},this.getStore(),e);i=t,g()}.bind(this),"function"==typeof n&&(n=n.bind(this)()),n)this[t]=n[t].bind(this);return u.bind(this)()}}}},render:function(r,u,d){void 0===d&&(d={}),i=Object.assign({},i,d),e=document.getElementById(u);var o=c(r());function a(){for(var e;e=f.pop();)e()}t=r,n=Object.assign({},o),e.appendChild(l(o,{initial:!0})),a(),window.addEventListener("__LITERAL_LIFECYCLE__",a)},h:function(e,t){for(var n=[],i=arguments.length-2;i-- >0;)n[i]=arguments[i+2];return{element:e,attributes:Object.assign({},t),children:function e(t,n){for(var i=0;i<t.length;i++)Array.isArray(t[i])?e(t[i],n):n.push(t[i]);return n}(n,[])}}};
var e,t,n,i={},r={},u="euid",d=[],o=[],s={},a={},f=[];function c(e){var t;if(void 0!==e){if("function"==typeof e.element){var n=Object.assign({},e.attributes.props)||{};delete e.attributes.props,(e=e.element(n)).render&&(t=e.uuid,(e=new e.render).uuid=t)}else"function"==typeof e.render&&(t=e.uuid,(e=new e.render).uuid=t);if(e.children)for(var i=0;i<e.children.length;i++)e.children[i]=c(e.children[i]);return e}}function h(e,t){void 0===t&&(t=!1);var n=typeof e;if("undefined"===n)return!1;if("string"===n||"number"===n)return document.createTextNode(e);if("boolean"===n)return document.createTextNode("");var i=document.createElement(e.element);if(t&&e.element&&e.uuid&&function(e){var t=a[e];t.mounted&&f.push(t.mounted);m()}(e.uuid),e.attributes&&"object"==typeof e.attributes)for(var r=0,u=Object.entries(e.attributes);r<u.length;r+=1){var d=u[r],o=d[0],s=d[1];"events"===o?v(s,i):"style"===o?l(s,i):i.setAttribute(o,s)}if(e.children&&e.children.length)for(var c=0;c<e.children.length;c++)i.appendChild(h(e.children[c],t));return i}function v(t,n){if(n){!function(t){for(var n=Object.keys(t),i=0;i<n.length;i++)d.push(n[i]);!function(){var t;for(;t=d.pop();)o.includes(t)||(o.push(t),e.addEventListener(t,function(e){var t=e.target.getAttribute("data-"+u);if(t&&s[t]){var n=e.type,i=s[t][n];i&&i(e)}}))}()}(t);var i=p();n.setAttribute("data-"+u,i),s[i]=t}}function l(e,t){if(e&&"object"==typeof e)for(var n=0,i=Object.entries(e);n<i.length;n+=1){var r=i[n];t.style[r[0]]=r[1]}}function b(i){var r=c(t()),d=Object.assign({},n);return n=Object.assign({},r),function e(t,n,i,r){void 0===r&&(r=0);if(!t)return;var d=typeof n;var o=typeof i;var c=t.childNodes[r];if("undefined"===o)t.appendChild(h(n)),C(n,"mounted");else if("undefined"===d)O(c),t.removeChild(c),C(i,"unmounted");else if(!1!==i||!n.element&&"string"!==d&&"number"!==d)if(!1!==n||!i.element&&"string"!==o&&"number"!==o){if(function(e,t,n,i){return n!==i||"string"===n&&e!==t||e.element!==t.element}(n,i,d,o))O(c),t.replaceChild(h(n),c),C(i,"unmounted"),C(n,"mounted");else if(n.element){!function(e,t,n){for(var i=0,r=Object.entries(t.attributes);i<r.length;i+=1){var u=r[i],d=u[0],o=u[1],s=n.attributes?n.attributes[d]:void 0;"style"===d?(void 0,void 0,h=typeof(f=s),"object"===(c=typeof(a=o))&&"object"===h&&JSON.stringify(a)===JSON.stringify(f)||"undefined"===c&&"undefined"===h||(e.removeAttribute("style"),l(o,e))):"events"===d?(O(e),v(o,e)):"value"===d&&o!==s?e.value=o:s&&o===s||e.setAttribute(d,o)}var a,f,c,h}(c,n,i),n.uuid===i.uuid?C(n,"updated"):n.uuid!==i.uuid&&(C(i,"unmounted"),C(n,"mounted"));var b=n.children?n.children.length:0,p=c.childNodes.length;if(b<p)for(var g=p-1;g>0;g--)if(void 0===n.children[g]){var y=c.lastChild;O(y),y.remove(),C(i.children[g],"unmounted")}for(var j=0;j<b;j++)e(c,n.children[j],i.children[j],j)}}else O(c),t.replaceChild(h(n),c),C(i,"unmounted");else O(c),t.replaceChild(h(n),c),C(n,"mounted");function O(e){if(e&&e.getAttribute){var t=e.getAttribute("data-"+u);t&&delete s[t]}}function C(e,t){if(e&&e.uuid){var n=a[e.uuid][t];n&&(f.push(n),m())}}}(e,r,d,0)}function m(){var e=new Event("__LITERAL_LIFECYCLE__");return window.dispatchEvent(e)}function p(){return Math.random().toString(36).substring(2)+(new Date).getTime().toString(36)}module.exports={component:function(e){void 0===e&&(e={});var t=e.state;void 0===t&&(t={});var n=e.mounted;void 0===n&&(n=function(){});var u=e.updated;void 0===u&&(u=function(){});var d=e.unmounted;void 0===d&&(d=function(){});var o=e.methods;void 0===o&&(o=function(){});var s=e.render;void 0===s&&(s=function(){});var f=p();return r[f]=t,function(e){return void 0===e&&(e={}),{uuid:f,render:function(){for(var t in this.uuid=f,this.props=e,this.mounted=n.bind(this),this.updated=u.bind(this),this.unmounted=d.bind(this),a[this.uuid]={mounted:this.mounted,updated:this.updated,unmounted:this.unmounted},this.getState=function(){return Object.assign({},r[this.uuid])}.bind(this),this.setState=function(e){var t=Object.assign({},this.getState(),e);r[this.uuid]=t,b()}.bind(this),this.getStore=function(){return Object.assign({},i)},this.setStore=function(e){var t=Object.assign({},this.getStore(),e);i=t,b()}.bind(this),"function"==typeof o&&(o=o.bind(this)()),o)this[t]=o[t].bind(this);return s.bind(this)()}}}},render:function(r,u,d){void 0===d&&(d={}),i=Object.assign({},i,d),e=document.getElementById(u);var o=c(r());function s(){for(var e;e=f.pop();)e()}t=r,n=Object.assign({},o),e.appendChild(h(o,!0)),s(),window.addEventListener("__LITERAL_LIFECYCLE__",s)},h:function(e,t){for(var n=[],i=arguments.length-2;i-- >0;)n[i]=arguments[i+2];return{element:e,attributes:Object.assign({},t),children:function e(t,n){for(var i=0;i<t.length;i++)Array.isArray(t[i])?e(t[i],n):n.push(t[i]);return n}(n,[])}}};
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

var e,t,n,i={},r={},u="luid",d="euid",o=[],a=[],s={},f=[],c=function(e,t){for(var n=[],i=arguments.length-2;i-- >0;)n[i]=arguments[i+2];return{element:e,attributes:Object.assign({},t),children:function e(t,n){for(var i=0;i<t.length;i++)Array.isArray(t[i])?e(t[i],n):n.push(t[i]);return n}(n,[])}},l=function(r,u,d){void 0===d&&(d={}),i=Object.assign({},i,d),e=document.getElementById(u);var o=h(r());function a(){for(var e;e=f.pop();)e()}t=r,n=Object.assign({},o),e.appendChild(b(o,{initial:!0})),a(),window.addEventListener("__LITERAL_LIFECYCLE__",a)},v=function(e){void 0===e&&(e={});var t=e.state;void 0===t&&(t={});var n=e.methods;void 0===n&&(n=function(){});var u=e.render;void 0===u&&(u=function(){});var d=T();return r[d]=t,function(e){return void 0===e&&(e={}),{uuid:d,render:function(){for(var t in this.uuid=d,this.props=e,this.getState=function(){return Object.assign({},r[this.uuid])}.bind(this),this.setState=function(e){var t=Object.assign({},this.getState(),e);r[this.uuid]=t,y(this.uuid)}.bind(this),this.getStore=function(){return Object.assign({},i)},this.setStore=function(e){var t=Object.assign({},this.getStore(),e);i=t,y()}.bind(this),"function"==typeof n&&(n=n.bind(this)()),n)this[t]=n[t].bind(this);return u.bind(this)()}}}};function h(e){var t;if(void 0!==e){if("function"==typeof e.render)t=e.uuid,(e=new e.render).uuid=t,e.attributes&&(e.attributes["data-"+u]=t);else if("function"==typeof e.element){var n=Object.assign({},e.attributes.props)||{};delete e.attributes.props,(e=e.element(n)).render&&(t=e.uuid,(e=new e.render).uuid=t,e.attributes&&(e.attributes["data-"+u]=t))}if(e.children)for(var i=0;i<e.children.length;i++)e.children[i]=h(e.children[i]);return e}}function b(e,t){void 0===t&&(t={});var n=t.mount;void 0===n&&(n=!0);var i=t.initial;void 0===i&&(i=!1);var r=typeof e;if("undefined"===r)return!1;if("string"===r||"number"===r)return document.createTextNode(e);if("boolean"===r)return document.createTextNode("");var u=document.createElement(e.element);if(e.attributes&&"object"==typeof e.attributes)for(var d=0,o=Object.entries(e.attributes);d<o.length;d+=1){var a=o[d],s=a[0],f=a[1];"events"===s?(g(f,u),m(f,n,i)):"style"===s?p(f,u):u.setAttribute(s,f)}if(e.children&&e.children.length)for(var c=0;c<e.children.length;c++)u.appendChild(b(e.children[c],{mount:n,initial:i}));return u}function g(t,n){if(n){!function(t){for(var n=Object.keys(t),i=0;i<n.length;i++)["mounted","updated","unmounted"].includes(n[i])||o.push(n[i]);!function(){var t;for(;t=o.pop();)a.includes(t)||(a.push(t),e.addEventListener(t,function(e){var t=e.target.getAttribute("data-"+d);if(t&&s[t]){var n=e.type,i=s[t][n];i&&i(e)}}))}()}(t);var i=T();n.setAttribute("data-"+d,i),s[i]=t}}function p(e,t){if(e&&"object"==typeof e)for(var n=0,i=Object.entries(e);n<i.length;n+=1){var r=i[n];t.style[r[0]]=r[1]}}function m(e,t,n){for(var i=0,r=Object.entries(e);i<r.length;i+=1){var u=r[i];d(u[0],u[1],t,n)}function d(e,t,n,i){i&&(n&&"mounted"===e&&f.push(t),n||"updated"!==e||f.push(t),O())}}function y(i){var r=h(t()),d=Object.assign({},n);n=Object.assign({},r);var o=e,a=e;if(!i)return j(o,r,d);o=document.querySelector("[data-"+u+'="'+i+'"]'),a=o.parentNode;var s=!1,f=function(e,t,n,i){if(!s){if(!e)return{newTree:void 0,oldTree:void 0};if(e.uuid&&e.uuid===n)return{newTree:e,oldTree:t};if(e.children)for(var r=e.children.length,u=0;u<r;u++){var d=e.children[u],o=t.children[u];d.uuid&&d.uuid===n?i(s={newTree:d,oldTree:o}):f(d,o,n,i)}}};f(r,d,i,function(e){for(var t=0;t<a.children.length;t++){var n=a.children[t].dataset[u];if(n&&n===i)return j(a,e.newTree,e.oldTree,t)}})}function j(e,t,n,i){if(void 0===i&&(i=0),e){var r=typeof t,u=typeof n,o=e.childNodes[i];if("undefined"===u)e.appendChild(b(t)),y(t,"mounted");else if("undefined"===r)m(o),e.removeChild(o),y(n,"unmounted");else if(!1!==n||!t.element&&"string"!==r&&"number"!==r)if(!1!==t||!n.element&&"string"!==u&&"number"!==u){if(function(e,t,n,i){return n!==i||"string"===n&&e!==t||e.element!==t.element}(t,n,r,u))m(o),e.replaceChild(b(t,{mount:!1}),o),y(n,"unmounted"),y(t,"mounted");else if(t.element){!function(e,t,n){for(var i=0,r=Object.entries(t.attributes);i<r.length;i+=1){var u=r[i],d=u[0],o=u[1],a=n.attributes?n.attributes[d]:void 0;if("style"===d){if(void 0,void 0,l=typeof(f=a),"object"===(c=typeof(s=o))&&"object"===l&&JSON.stringify(s)===JSON.stringify(f)||"undefined"===c&&"undefined"===l)return;e.removeAttribute("style"),p(o,e)}else"events"===d?(m(e),g(o,e)):"value"===d&&o!==a?e.value=o:a&&o===a||e.setAttribute(d,o)}var s,f,c,l}(o,t,n),y(t,"updated");var a=t.children?t.children.length:0,c=o.childNodes.length;if(a<c)for(var l=c-1;l>0;l--)if(void 0===t.children[l]){var v=o.lastChild;m(v),v.remove(),y(n.children[l],"unmounted")}for(var h=0;h<a;h++)j(o,t.children[h],n.children[h],h)}}else m(o),e.replaceChild(b(t),o),y(n,"unmounted"),y(t,"mounted");else m(o),e.replaceChild(b(t),o),y(n,"unmounted"),y(t,"mounted")}function m(e){if(e&&e.getAttribute){var t=e.getAttribute("data-"+d);t&&delete s[t]}}function y(e,t){if(e&&e.attributes&&e.attributes.events){for(var n=0,i=Object.entries(e.attributes.events);n<i.length;n+=1){var r=i[n];r[0]===t&&f.push(r[1])}O()}}}function O(){var e=new Event("__LITERAL_LIFECYCLE__");return window.dispatchEvent(e)}function T(){return Math.random().toString(36).substring(2)+(new Date).getTime().toString(36)}export default{component:v,render:l,h:c};export{c as h,l as render,v as component};
var e,t,n,i={},r={},u="euid",d=[],o=[],s={},a={},f=[],c=function(e,t){for(var n=[],i=arguments.length-2;i-- >0;)n[i]=arguments[i+2];return{element:e,attributes:Object.assign({},t),children:function e(t,n){for(var i=0;i<t.length;i++)Array.isArray(t[i])?e(t[i],n):n.push(t[i]);return n}(n,[])}},h=function(r,u,d){void 0===d&&(d={}),i=Object.assign({},i,d),e=document.getElementById(u);var o=l(r());function s(){for(var e;e=f.pop();)e()}t=r,n=Object.assign({},o),e.appendChild(b(o,!0)),s(),window.addEventListener("__LITERAL_LIFECYCLE__",s)},v=function(e){void 0===e&&(e={});var t=e.state;void 0===t&&(t={});var n=e.mounted;void 0===n&&(n=function(){});var u=e.updated;void 0===u&&(u=function(){});var d=e.unmounted;void 0===d&&(d=function(){});var o=e.methods;void 0===o&&(o=function(){});var s=e.render;void 0===s&&(s=function(){});var f=j();return r[f]=t,function(e){return void 0===e&&(e={}),{uuid:f,render:function(){for(var t in this.uuid=f,this.props=e,this.mounted=n.bind(this),this.updated=u.bind(this),this.unmounted=d.bind(this),a[this.uuid]={mounted:this.mounted,updated:this.updated,unmounted:this.unmounted},this.getState=function(){return Object.assign({},r[this.uuid])}.bind(this),this.setState=function(e){var t=Object.assign({},this.getState(),e);r[this.uuid]=t,g(this.uuid)}.bind(this),this.getStore=function(){return Object.assign({},i)},this.setStore=function(e){var t=Object.assign({},this.getStore(),e);i=t,g()}.bind(this),"function"==typeof o&&(o=o.bind(this)()),o)this[t]=o[t].bind(this);return s.bind(this)()}}}};function l(e){var t;if(void 0!==e){if("function"==typeof e.element){var n=Object.assign({},e.attributes.props)||{};delete e.attributes.props,(e=e.element(n)).render&&(t=e.uuid,(e=new e.render).uuid=t)}else"function"==typeof e.render&&(t=e.uuid,(e=new e.render).uuid=t);if(e.children)for(var i=0;i<e.children.length;i++)e.children[i]=l(e.children[i]);return e}}function b(e,t){void 0===t&&(t=!1);var n=typeof e;if("undefined"===n)return!1;if("string"===n||"number"===n)return document.createTextNode(e);if("boolean"===n)return document.createTextNode("");var i=document.createElement(e.element);if(t&&e.element&&e.uuid&&function(e){var t=a[e];t.mounted&&f.push(t.mounted);y()}(e.uuid),e.attributes&&"object"==typeof e.attributes)for(var r=0,u=Object.entries(e.attributes);r<u.length;r+=1){var d=u[r],o=d[0],s=d[1];"events"===o?m(s,i):"style"===o?p(s,i):i.setAttribute(o,s)}if(e.children&&e.children.length)for(var c=0;c<e.children.length;c++)i.appendChild(b(e.children[c],t));return i}function m(t,n){if(n){!function(t){for(var n=Object.keys(t),i=0;i<n.length;i++)d.push(n[i]);!function(){var t;for(;t=d.pop();)o.includes(t)||(o.push(t),e.addEventListener(t,function(e){var t=e.target.getAttribute("data-"+u);if(t&&s[t]){var n=e.type,i=s[t][n];i&&i(e)}}))}()}(t);var i=j();n.setAttribute("data-"+u,i),s[i]=t}}function p(e,t){if(e&&"object"==typeof e)for(var n=0,i=Object.entries(e);n<i.length;n+=1){var r=i[n];t.style[r[0]]=r[1]}}function g(i){var r=l(t()),d=Object.assign({},n);return n=Object.assign({},r),function e(t,n,i,r){void 0===r&&(r=0);if(!t)return;var d=typeof n;var o=typeof i;var c=t.childNodes[r];if("undefined"===o)t.appendChild(b(n)),C(n,"mounted");else if("undefined"===d)O(c),t.removeChild(c),C(i,"unmounted");else if(!1!==i||!n.element&&"string"!==d&&"number"!==d)if(!1!==n||!i.element&&"string"!==o&&"number"!==o){if(function(e,t,n,i){return n!==i||"string"===n&&e!==t||e.element!==t.element}(n,i,d,o))O(c),t.replaceChild(b(n),c),C(i,"unmounted"),C(n,"mounted");else if(n.element){!function(e,t,n){for(var i=0,r=Object.entries(t.attributes);i<r.length;i+=1){var u=r[i],d=u[0],o=u[1],s=n.attributes?n.attributes[d]:void 0;"style"===d?(void 0,void 0,h=typeof(f=s),"object"===(c=typeof(a=o))&&"object"===h&&JSON.stringify(a)===JSON.stringify(f)||"undefined"===c&&"undefined"===h||(e.removeAttribute("style"),p(o,e))):"events"===d?(O(e),m(o,e)):"value"===d&&o!==s?e.value=o:s&&o===s||e.setAttribute(d,o)}var a,f,c,h}(c,n,i),n.uuid===i.uuid?C(n,"updated"):n.uuid!==i.uuid&&(C(i,"unmounted"),C(n,"mounted"));var h=n.children?n.children.length:0,v=c.childNodes.length;if(h<v)for(var l=v-1;l>0;l--)if(void 0===n.children[l]){var g=c.lastChild;O(g),g.remove(),C(i.children[l],"unmounted")}for(var j=0;j<h;j++)e(c,n.children[j],i.children[j],j)}}else O(c),t.replaceChild(b(n),c),C(i,"unmounted");else O(c),t.replaceChild(b(n),c),C(n,"mounted");function O(e){if(e&&e.getAttribute){var t=e.getAttribute("data-"+u);t&&delete s[t]}}function C(e,t){if(e&&e.uuid){var n=a[e.uuid][t];n&&(f.push(n),y())}}}(e,r,d,0)}function y(){var e=new Event("__LITERAL_LIFECYCLE__");return window.dispatchEvent(e)}function j(){return Math.random().toString(36).substring(2)+(new Date).getTime().toString(36)}export default{component:v,render:h,h:c};export{c as h,h as render,v as component};
//# sourceMappingURL=index.m.js.map

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.literaljs=t()}(this,function(){var e,t,n,i={},r={},u="luid",d="euid",o=[],a=[],s={},f=[];function c(e){var t;if(void 0!==e){if("function"==typeof e.render)t=e.uuid,(e=new e.render).uuid=t,e.attributes&&(e.attributes["data-"+u]=t);else if("function"==typeof e.element){var n=Object.assign({},e.attributes.props)||{};delete e.attributes.props,(e=e.element(n)).render&&(t=e.uuid,(e=new e.render).uuid=t,e.attributes&&(e.attributes["data-"+u]=t))}if(e.children)for(var i=0;i<e.children.length;i++)e.children[i]=c(e.children[i]);return e}}function l(e,t){void 0===t&&(t={});var n=t.mount;void 0===n&&(n=!0);var i=t.initial;void 0===i&&(i=!1);var r=typeof e;if("undefined"===r)return!1;if("string"===r||"number"===r)return document.createTextNode(e);if("boolean"===r)return document.createTextNode("");var u=document.createElement(e.element);if(e.attributes&&"object"==typeof e.attributes)for(var d=0,o=Object.entries(e.attributes);d<o.length;d+=1){var a=o[d],s=a[0],f=a[1];"events"===s?(v(f,u),b(f,n,i)):"style"===s?h(f,u):u.setAttribute(s,f)}if(e.children&&e.children.length)for(var c=0;c<e.children.length;c++)u.appendChild(l(e.children[c],{mount:n,initial:i}));return u}function v(t,n){if(n){!function(t){for(var n=Object.keys(t),i=0;i<n.length;i++)["mounted","updated","unmounted"].includes(n[i])||o.push(n[i]);!function(){var t;for(;t=o.pop();)a.includes(t)||(a.push(t),e.addEventListener(t,function(e){var t=e.target.getAttribute("data-"+d);if(t&&s[t]){var n=e.type,i=s[t][n];i&&i(e)}}))}()}(t);var i=y();n.setAttribute("data-"+d,i),s[i]=t}}function h(e,t){if(e&&"object"==typeof e)for(var n=0,i=Object.entries(e);n<i.length;n+=1){var r=i[n];t.style[r[0]]=r[1]}}function b(e,t,n){for(var i=0,r=Object.entries(e);i<r.length;i+=1){var u=r[i];d(u[0],u[1],t,n)}function d(e,t,n,i){i&&(n&&"mounted"===e&&f.push(t),n||"updated"!==e||f.push(t),m())}}function p(i){var r=c(t()),d=Object.assign({},n);n=Object.assign({},r);var o=e,a=e;if(!i)return g(o,r,d);o=document.querySelector("[data-"+u+'="'+i+'"]'),a=o.parentNode;var s=!1,f=function(e,t,n,i){if(!s){if(!e)return{newTree:void 0,oldTree:void 0};if(e.uuid&&e.uuid===n)return{newTree:e,oldTree:t};if(e.children)for(var r=e.children.length,u=0;u<r;u++){var d=e.children[u],o=t.children[u];d.uuid&&d.uuid===n?i(s={newTree:d,oldTree:o}):f(d,o,n,i)}}};f(r,d,i,function(e){for(var t=0;t<a.children.length;t++){var n=a.children[t].dataset[u];if(n&&n===i)return g(a,e.newTree,e.oldTree,t)}})}function g(e,t,n,i){if(void 0===i&&(i=0),e){var r=typeof t,u=typeof n,o=e.childNodes[i];if("undefined"===u)e.appendChild(l(t)),O(t,"mounted");else if("undefined"===r)j(o),e.removeChild(o),O(n,"unmounted");else if(!1!==n||!t.element&&"string"!==r&&"number"!==r)if(!1!==t||!n.element&&"string"!==u&&"number"!==u){if(function(e,t,n,i){return n!==i||"string"===n&&e!==t||e.element!==t.element}(t,n,r,u))j(o),e.replaceChild(l(t,{mount:!1}),o),O(n,"unmounted"),O(t,"mounted");else if(t.element){!function(e,t,n){for(var i=0,r=Object.entries(t.attributes);i<r.length;i+=1){var u=r[i],d=u[0],o=u[1],a=n.attributes?n.attributes[d]:void 0;if("style"===d){if(void 0,void 0,l=typeof(f=a),"object"===(c=typeof(s=o))&&"object"===l&&JSON.stringify(s)===JSON.stringify(f)||"undefined"===c&&"undefined"===l)return;e.removeAttribute("style"),h(o,e)}else"events"===d?(j(e),v(o,e)):"value"===d&&o!==a?e.value=o:a&&o===a||e.setAttribute(d,o)}var s,f,c,l}(o,t,n),O(t,"updated");var a=t.children?t.children.length:0,c=o.childNodes.length;if(a<c)for(var b=c-1;b>0;b--)if(void 0===t.children[b]){var p=o.lastChild;j(p),p.remove(),O(n.children[b],"unmounted")}for(var y=0;y<a;y++)g(o,t.children[y],n.children[y],y)}}else j(o),e.replaceChild(l(t),o),O(n,"unmounted"),O(t,"mounted");else j(o),e.replaceChild(l(t),o),O(n,"unmounted"),O(t,"mounted")}function j(e){if(e&&e.getAttribute){var t=e.getAttribute("data-"+d);t&&delete s[t]}}function O(e,t){if(e&&e.attributes&&e.attributes.events){for(var n=0,i=Object.entries(e.attributes.events);n<i.length;n+=1){var r=i[n];r[0]===t&&f.push(r[1])}m()}}}function m(){var e=new Event("__LITERAL_LIFECYCLE__");return window.dispatchEvent(e)}function y(){return Math.random().toString(36).substring(2)+(new Date).getTime().toString(36)}return{component:function(e){void 0===e&&(e={});var t=e.state;void 0===t&&(t={});var n=e.methods;void 0===n&&(n=function(){});var u=e.render;void 0===u&&(u=function(){});var d=y();return r[d]=t,function(e){return void 0===e&&(e={}),{uuid:d,render:function(){for(var t in this.uuid=d,this.props=e,this.getState=function(){return Object.assign({},r[this.uuid])}.bind(this),this.setState=function(e){var t=Object.assign({},this.getState(),e);r[this.uuid]=t,p(this.uuid)}.bind(this),this.getStore=function(){return Object.assign({},i)},this.setStore=function(e){var t=Object.assign({},this.getStore(),e);i=t,p()}.bind(this),"function"==typeof n&&(n=n.bind(this)()),n)this[t]=n[t].bind(this);return u.bind(this)()}}}},render:function(r,u,d){void 0===d&&(d={}),i=Object.assign({},i,d),e=document.getElementById(u);var o=c(r());function a(){for(var e;e=f.pop();)e()}t=r,n=Object.assign({},o),e.appendChild(l(o,{initial:!0})),a(),window.addEventListener("__LITERAL_LIFECYCLE__",a)},h:function(e,t){for(var n=[],i=arguments.length-2;i-- >0;)n[i]=arguments[i+2];return{element:e,attributes:Object.assign({},t),children:function e(t,n){for(var i=0;i<t.length;i++)Array.isArray(t[i])?e(t[i],n):n.push(t[i]);return n}(n,[])}}}});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.literaljs=t()}(this,function(){var e,t,n,i={},r={},u="euid",d=[],o=[],s={},a={},f=[];function c(e){var t;if(void 0!==e){if("function"==typeof e.element){var n=Object.assign({},e.attributes.props)||{};delete e.attributes.props,(e=e.element(n)).render&&(t=e.uuid,(e=new e.render).uuid=t)}else"function"==typeof e.render&&(t=e.uuid,(e=new e.render).uuid=t);if(e.children)for(var i=0;i<e.children.length;i++)e.children[i]=c(e.children[i]);return e}}function h(e,t){void 0===t&&(t=!1);var n=typeof e;if("undefined"===n)return!1;if("string"===n||"number"===n)return document.createTextNode(e);if("boolean"===n)return document.createTextNode("");var i=document.createElement(e.element);if(t&&e.element&&e.uuid&&function(e){var t=a[e];t.mounted&&f.push(t.mounted);m()}(e.uuid),e.attributes&&"object"==typeof e.attributes)for(var r=0,u=Object.entries(e.attributes);r<u.length;r+=1){var d=u[r],o=d[0],s=d[1];"events"===o?l(s,i):"style"===o?v(s,i):i.setAttribute(o,s)}if(e.children&&e.children.length)for(var c=0;c<e.children.length;c++)i.appendChild(h(e.children[c],t));return i}function l(t,n){if(n){!function(t){for(var n=Object.keys(t),i=0;i<n.length;i++)d.push(n[i]);!function(){var t;for(;t=d.pop();)o.includes(t)||(o.push(t),e.addEventListener(t,function(e){var t=e.target.getAttribute("data-"+u);if(t&&s[t]){var n=e.type,i=s[t][n];i&&i(e)}}))}()}(t);var i=p();n.setAttribute("data-"+u,i),s[i]=t}}function v(e,t){if(e&&"object"==typeof e)for(var n=0,i=Object.entries(e);n<i.length;n+=1){var r=i[n];t.style[r[0]]=r[1]}}function b(i){var r=c(t()),d=Object.assign({},n);return n=Object.assign({},r),function e(t,n,i,r){void 0===r&&(r=0);if(!t)return;var d=typeof n;var o=typeof i;var c=t.childNodes[r];if("undefined"===o)t.appendChild(h(n)),C(n,"mounted");else if("undefined"===d)O(c),t.removeChild(c),C(i,"unmounted");else if(!1!==i||!n.element&&"string"!==d&&"number"!==d)if(!1!==n||!i.element&&"string"!==o&&"number"!==o){if(function(e,t,n,i){return n!==i||"string"===n&&e!==t||e.element!==t.element}(n,i,d,o))O(c),t.replaceChild(h(n),c),C(i,"unmounted"),C(n,"mounted");else if(n.element){!function(e,t,n){for(var i=0,r=Object.entries(t.attributes);i<r.length;i+=1){var u=r[i],d=u[0],o=u[1],s=n.attributes?n.attributes[d]:void 0;"style"===d?(void 0,void 0,h=typeof(f=s),"object"===(c=typeof(a=o))&&"object"===h&&JSON.stringify(a)===JSON.stringify(f)||"undefined"===c&&"undefined"===h||(e.removeAttribute("style"),v(o,e))):"events"===d?(O(e),l(o,e)):"value"===d&&o!==s?e.value=o:s&&o===s||e.setAttribute(d,o)}var a,f,c,h}(c,n,i),n.uuid===i.uuid?C(n,"updated"):n.uuid!==i.uuid&&(C(i,"unmounted"),C(n,"mounted"));var b=n.children?n.children.length:0,p=c.childNodes.length;if(b<p)for(var g=p-1;g>0;g--)if(void 0===n.children[g]){var y=c.lastChild;O(y),y.remove(),C(i.children[g],"unmounted")}for(var j=0;j<b;j++)e(c,n.children[j],i.children[j],j)}}else O(c),t.replaceChild(h(n),c),C(i,"unmounted");else O(c),t.replaceChild(h(n),c),C(n,"mounted");function O(e){if(e&&e.getAttribute){var t=e.getAttribute("data-"+u);t&&delete s[t]}}function C(e,t){if(e&&e.uuid){var n=a[e.uuid][t];n&&(f.push(n),m())}}}(e,r,d,0)}function m(){var e=new Event("__LITERAL_LIFECYCLE__");return window.dispatchEvent(e)}function p(){return Math.random().toString(36).substring(2)+(new Date).getTime().toString(36)}return{component:function(e){void 0===e&&(e={});var t=e.state;void 0===t&&(t={});var n=e.mounted;void 0===n&&(n=function(){});var u=e.updated;void 0===u&&(u=function(){});var d=e.unmounted;void 0===d&&(d=function(){});var o=e.methods;void 0===o&&(o=function(){});var s=e.render;void 0===s&&(s=function(){});var f=p();return r[f]=t,function(e){return void 0===e&&(e={}),{uuid:f,render:function(){for(var t in this.uuid=f,this.props=e,this.mounted=n.bind(this),this.updated=u.bind(this),this.unmounted=d.bind(this),a[this.uuid]={mounted:this.mounted,updated:this.updated,unmounted:this.unmounted},this.getState=function(){return Object.assign({},r[this.uuid])}.bind(this),this.setState=function(e){var t=Object.assign({},this.getState(),e);r[this.uuid]=t,b()}.bind(this),this.getStore=function(){return Object.assign({},i)},this.setStore=function(e){var t=Object.assign({},this.getStore(),e);i=t,b()}.bind(this),"function"==typeof o&&(o=o.bind(this)()),o)this[t]=o[t].bind(this);return s.bind(this)()}}}},render:function(r,u,d){void 0===d&&(d={}),i=Object.assign({},i,d),e=document.getElementById(u);var o=c(r());function s(){for(var e;e=f.pop();)e()}t=r,n=Object.assign({},o),e.appendChild(h(o,!0)),s(),window.addEventListener("__LITERAL_LIFECYCLE__",s)},h:function(e,t){for(var n=[],i=arguments.length-2;i-- >0;)n[i]=arguments[i+2];return{element:e,attributes:Object.assign({},t),children:function e(t,n){for(var i=0;i<t.length;i++)Array.isArray(t[i])?e(t[i],n):n.push(t[i]);return n}(n,[])}}}});
//# sourceMappingURL=index.umd.js.map
{
"name": "literaljs",
"version": "5.0.2",
"version": "5.1.0",
"description": "A small JavaScript library for building reactive user interfaces.",

@@ -5,0 +5,0 @@ "main": "build/index.js",

@@ -12,19 +12,19 @@ <p align="center">

Recent 5.0.2 microbundle:
Recent 5.1.0 microbundle:
```js
$ microbundle
Build output to build:
2.02 kB: index.js
2.04 kB: index.m.js
2.07 kB: index.umd.js
1.8 kB: index.js
1.83 kB: index.m.js
1.86 kB: index.umd.js
```
### [Features and stuff](#features)
- **Small**: Only around 2kb in size (using microbundle).
- **Small**: Less than 2kb in size (using microbundle).
- **Fast**: Current and previous vDOM data is diffed instead of the actual DOM for performant updates and rendering.
- **Virtual DOM**: Diffing occurs only on state and store update for more efficient DOM updates.
- **Flexible Syntax**: Freedom to use JSX, Hyperscript, or Object syntax.
- **Lifecycle Methods**: All DOM elements have the ability to trigger `mounted`, `updated`, and `unmounted` lifecycle functions.
- **Lifecycle Methods**: Components have the ability to trigger `mounted`, `updated`, and `unmounted` lifecycle functions.
- **Local Component State**: Every component can manage state locally.
- **Global Application Store**: One source of truth which makes other state management libraries (like Redux) less of a need.
- **Event Delegation**: Uses event delegation and only event types defined within the application for increased performance.

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc