Comparing version 0.0.20 to 0.0.21
@@ -7,2 +7,6 @@ # Change Log | ||
## [0.0.21] - 2018-05-11 | ||
- **Improvement** security | ||
- **Fixed** observer issue | ||
## [0.0.20] - 2018-05-09 | ||
@@ -9,0 +13,0 @@ - **Fixed** xss vulnerability |
@@ -1,2 +0,2 @@ | ||
// [DOZ] Build version: 0.0.20 | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("Doz",[],t):"object"==typeof exports?exports.Doz=t():e.Doz=t()}("undefined"!=typeof self?self:this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=9)}([function(e,t,r){"use strict";e.exports={ROOT:"__DOZ_GLOBAL_COMPONENTS__",INSTANCE:"__DOZ_INSTANCE__",TAG:{ROOT:"doz-root",EACH:"doz-each-root",VIEW:"doz-view",SUFFIX_ROOT:"-root"},REGEX:{IS_CUSTOM_TAG:/^\w+-[\w-]+$/,IS_CUSTOM_TAG_STRING:/<\w+-[\w-]+/,IS_BIND:/^d-bind$/,IS_REF:/^d-ref$/,IS_ALIAS:/^d:alias$/,IS_STORE:/^d:store$/,IS_COMPONENT_LISTENER:/^d:on-(\w+)$/,IS_LISTENER:/^on/,IS_ID_SELECTOR:/^#[\w-_:.]+$/,IS_PARENT_METHOD:/^parent.(.*)/,IS_STRING_QUOTED:/^"\w+"/,GET_LISTENER:/^this.(.*)\((.*)\)/,TRIM_QUOTES:/^["'](.*)["']$/},ATTR:{BIND:"d-bind",REF:"d-ref",ALIAS:"d:alias",STORE:"d:store",LISTENER:"d:on",ID:"d:id"}}},function(e,t,r){"use strict";function n(){return window[u]=window[u]||{components:{}},window[u].components}function o(e){var t=n(),r=e.tag.toUpperCase();if(t.hasOwnProperty(r))throw new Error("Component "+r+" already defined");t[r]=e}function i(){window[u]&&(window[u].components={})}function a(e){if("string"!=typeof e)throw new TypeError("tag must be a string");return e=e.toUpperCase(),n()[e]}var c=r(0),u=c.ROOT;e.exports={register:o,get:a,removeAll:i}},function(e,t,r){"use strict";function n(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];for(var o in t)t.hasOwnProperty(o)&&-1===r.indexOf(o)&&(e.hasOwnProperty(o)&&void 0!==e[o]?"object"===i(e[o])&&n(e[o],t[o]):e[o]=t[o]);return e}function o(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return t[0]=Object.assign({},t[0]),n.apply(this,t)}var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};e.exports=n,e.exports.copy=o},function(e,t,r){"use strict";function n(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("string"!=typeof e)throw new TypeError("Tag must be a string");if(!h.IS_CUSTOM_TAG.test(e))throw new TypeError("Tag must contain a dash (-) like my-component");var r={};r.tag=e,r.cfg=s.copy(t,{updateChildrenProps:!0,props:{},template:function(){return"<div></div>"}}),f(r)}function o(){function e(o){for(var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};o;){var c=t.autoCmp||m.get(o.nodeName)||t.view._components[o.nodeName.toLowerCase()];if(c){var u=w(o),s=x(u),l=i(c,{root:o,view:t.view,props:u,dProps:s,parentCmp:a.cmp,isStatic:t.isStatic});if(!l)continue;if(l.render(!0),r||(r=l),o.insertBefore(l._rootElement,o.firstChild),g.callRender(l),n=l,a.cmp){var f=Object.keys(a.cmp.children).length;a.cmp.children[l.alias?l.alias:f++]=l}t.autoCmp=null}o.hasChildNodes()&&e(o.firstChild,{cmp:n}),o=o.nextSibling}}var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t.template="string"==typeof t.template?p.create(t.template):t.template,t.root.appendChild(t.template);var r=null,n=void 0;return e(t.template),r}function i(e,t){var r=s.copy(t.props,"function"==typeof e.cfg.props?e.cfg.props():e.cfg.props),n=Object.defineProperties({},{_isCreated:{value:!1,writable:!0},_prevTpl:{value:null,writable:!0},_prev:{value:null,writable:!0},_prevProps:{value:null,writable:!0},_rootElement:{value:null,writable:!0},_boundElements:{value:{},writable:!0},_callback:{value:t.dProps.callback,writable:!0},_cache:{value:new Map},_loops:{value:{},writable:!0},_isStatic:{value:t.isStatic},_publicProps:{value:Object.assign({},t.props)},_processing:{value:[],writable:!0},_dynamicChildren:{value:[],writable:!0},view:{value:t.view,enumerable:!0},parent:{value:t.parentCmp,enumerable:!0},ref:{value:{},writable:!0,enumerable:!0},children:{value:{},writable:!0,enumerable:!0},tag:{value:e.tag,enumerable:!0},emit:{value:function(e){if(this._callback&&void 0!==this._callback[e]&&void 0!==this.parent[this._callback[e]]&&"function"==typeof this.parent[this._callback[e]]){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];this.parent[this._callback[e]].apply(this.parent,r)}},enumerable:!0},each:{value:function(e,t){if(Array.isArray(e))return e.map(t).map(function(e){return e=e.trim()}).join("")},enumerable:!0},getStore:{value:function(e){return this.view.getStore(e)},enumerable:!0},getComponentById:{value:function(e){return this.view.getComponentById(e)},enumerable:!0},action:{value:t.view.action,enumerable:!0},render:{value:function(e){var r=this.template().trim(),n=p.create(r,v.ROOT),o=_(n),i=S(t.root,o,this._prev,0,this,e);u(this),!this._rootElement&&i&&(this._rootElement=i),this._prev=o},enumerable:!0},mount:{value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this._rootElement;return"string"==typeof t.selector?r=r.querySelector(t.selector):t.selector instanceof HTMLElement&&(r=t.selector),this.view.mount(e,r,this)},enumerable:!0},destroy:{value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];(t||this._rootElement&&!1!==g.callBeforeDestroy(this)&&this._rootElement.parentNode)&&(Object.keys(this.children).forEach(function(t){e.children[t].destroy()}),t?this._rootElement.parentNode.innerHTML="":this._rootElement.parentNode.parentNode.removeChild(this._rootElement.parentNode),g.callDestroy(this))},enumerable:!0}});if(a(n,e.cfg,t.dProps),!1!==g.callBeforeCreate(n))return b.create(n,r),T.create(n),O.create(n),g.callCreate(n),n._isCreated=!0,n}function a(e,t,r){Object.assign(e,t,r)}function c(e){for(var t=e._dynamicChildren.length-1;t>=0;){var r=e._dynamicChildren[t];!document.body.contains(r)&&r[y]&&(r[y].destroy(!0),e._dynamicChildren.splice(t,1)),t-=1}}function u(e){c(e);for(var t=e._processing.length-1;t>=0;){var r=e._processing[t],n=r.node.parentNode;r.node[y]&&r.node[y].destroy(!0);var i=o({root:n,template:r.node.outerHTML,view:e.view});e._dynamicChildren.push(i._rootElement.parentNode),n.replaceChild(i._rootElement.parentNode,r.node),i._rootElement.parentNode[y]=i,e._processing.splice(t,1),t-=1}}var s=r(2),l=r(1),f=l.register,p=r(4),d=r(0),h=d.REGEX,v=d.TAG,y=d.INSTANCE,m=r(1),b=r(13),g=r(5),E=r(6),_=E.transform,w=E.serializeProps,S=r(8).updateElement,T=r(18),O=r(19),C=r(20),x=C.extract;e.exports={component:n,getInstances:o}},function(e,t,r){"use strict";var n=/\n/g,o=/\s+/g,i={create:function(e,t){var r=void 0;e=e.replace(n," "),e=e.replace(o," ");var i=document.createElement("div");if(i.innerHTML=e,i.childNodes.length>1?(r=document.createElement(t),r.innerHTML=i.innerHTML):r=i.firstChild||document.createTextNode(""),!this.isValidNode(r))throw new Error("Element not valid");return r},isValidNode:function(e){return e&&"nodeType"in e},getAllNodes:function(e){function t(e){for(;e;)r.push(e),e.hasChildNodes()&&t(e.firstChild),e=e.nextSibling}var r=[];return t(e),r}};e.exports=i},function(e,t,r){"use strict";function n(e){if("function"==typeof e.onBeforeCreate)return e.onBeforeCreate.call(e)}function o(e){"function"==typeof e.onCreate&&e.onCreate.call(e)}function i(e){"function"==typeof e.onRender&&e.onRender.call(e)}function a(e){if("function"==typeof e.onBeforeUpdate)return e.onBeforeUpdate.call(e,Object.assign({},e.props))}function c(e){"function"==typeof e.onUpdate&&e.onUpdate.call(e)}function u(e){if("function"==typeof e.onBeforeDestroy)return e.onBeforeDestroy.call(e)}function s(e){"function"==typeof e.onDestroy&&(e.onDestroy.call(e),e=null)}e.exports={callBeforeCreate:n,callCreate:o,callRender:i,callBeforeUpdate:a,callUpdate:c,callBeforeDestroy:u,callDestroy:s}},function(e,t,r){"use strict";function n(e){var t={};if(e.attributes)for(var r=Array.from(e.attributes),n=r.length-1;n>=0;--n){var o=r[n],a=o.name.match(c.IS_COMPONENT_LISTENER);if(a)void 0===t[u.LISTENER]&&(t[u.LISTENER]={}),t[u.LISTENER][a[1]]=o.nodeValue,delete t[o.name];else{var s=o.nodeValue;c.IS_STRING_QUOTED.test(s)&&(s=o.nodeValue.replace(/"/g,""")),t[o.name]=""===s||i(s)}}return t}function o(e){function t(e,o){for(;e;){var i=void 0;3===e.nodeType?i=e.nodeValue:(i={},i.type=e.nodeName.toLowerCase(),i.children=[],i.props=n(e)),Object.keys(r).length||(r=i),o&&o.children&&o.children.push(i),e.hasChildNodes()&&t(e.firstChild,i),e=e.nextSibling}}var r={};return t(e,r),r}var i=r(7),a=r(0),c=a.REGEX,u=a.ATTR;e.exports={transform:o,serializeProps:n}},function(e,t,r){"use strict";function n(e){if("string"!=typeof e)return e;switch(e){case"undefined":return;case"null":return null;case"NaN":return NaN;case"Infinity":return 1/0;case"true":return!0;case"false":return!1;case"0":return e;default:try{return JSON.parse(e)}catch(e){}}var t=parseFloat(e);return!isNaN(t)&&isFinite(e)?0===e.toLowerCase().indexOf("0x")?parseInt(e,16):t:e}e.exports=n},function(e,t,r){"use strict";var n=r(15);e.exports={updateElement:n.update}},function(e,t,r){"use strict";e.exports=r(10)},function(e,t,r){"use strict";e.exports=r(11),e.exports.component=r(3).component,e.exports.collection=r(1),e.exports.update=r(8).updateElement,e.exports.transform=r(6).transform,e.exports.html=r(4)},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),a=r(2),c=r(12),u=r(3),s=r(0),l=s.TAG,f=s.REGEX,p=function(){function e(){var t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};n(this,e);var i="<"+l.VIEW+"></"+l.VIEW+">";if(f.IS_ID_SELECTOR.test(r.root)&&(r.root=document.getElementById(r.root.substring(1))),f.IS_ID_SELECTOR.test(r.template)&&(r.template=document.getElementById(r.template.substring(1)),r.template=r.template.innerHTML),!(r.root instanceof HTMLElement))throw new TypeError("root must be an HTMLElement or an valid ID selector like #example-root");if(!(r.template instanceof HTMLElement||"string"==typeof r.template||"function"==typeof r.template))throw new TypeError("template must be a string or an HTMLElement or a function or an valid ID selector like #example-template");this.cfg=a(r,{components:[],actions:{}}),Object.defineProperties(this,{_components:{value:{},writable:!0},_usedComponents:{value:{},writable:!0},_stores:{value:{},writable:!0},_cache:{value:new Map},_ids:{value:{},writable:!0},action:{value:c(this.cfg.actions,this),enumerable:!0},mount:{value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this._tree;if("string"==typeof t&&(t=document.querySelector(t)),!((t=t||r._rootElement)instanceof HTMLElement))throw new TypeError("root must be an HTMLElement or an valid selector like #example-root");var n={tag:l.ROOT,cfg:{props:{},template:function(){return e}}};return u.getInstances({root:t,template:"<"+l.ROOT+"></"+l.ROOT+">",view:this,parentCmp:r,isStatic:!1,autoCmp:n,mount:!0})},enumerable:!0}}),this.cfg.components.forEach(function(e){"object"===(void 0===e?"undefined":o(e))&&"string"==typeof e.tag&&"object"===o(e.cfg)&&(t._components[e.tag]=e)}),this._components[l.VIEW]={tag:l.VIEW,cfg:{props:r.props||{},template:function(){return"function"==typeof r.template?r.template():r.template}}},this._tree=u.getInstances({root:this.cfg.root,template:i,view:this})||[]}return i(e,[{key:"getComponent",value:function(e){return this._tree?this._tree.children[e]:void 0}},{key:"getComponentById",value:function(e){return this._ids[e]}},{key:"getStore",value:function(e){return this._stores[e]}}]),e}();e.exports=p},function(e,t,r){"use strict";function n(e,t){if("object"!==(void 0===e?"undefined":o(e)))throw new TypeError("expected an object");for(var r=Object.assign({},e),i=Object.keys(e),a=i.length-1;a>=0;--a){var c=r[i[a]];"function"==typeof c?r[i[a]]=c.bind(t):"object"===(void 0===c?"undefined":o(c))&&(r[i[a]]=n(c,t))}return r}var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};e.exports=n},function(e,t,r){"use strict";function n(e){return void 0!==window.requestAnimationFrame?window.requestAnimationFrame(e):window.setTimeout(e)}function o(e,t){if(e.updateChildrenProps){Object.keys(e.children).forEach(function(r){t.forEach(function(t){e.children[r]._publicProps.hasOwnProperty(t.currentPath)&&e.children[r].props.hasOwnProperty(t.currentPath)&&(e.children[r].props[t.currentPath]=t.newValue)})})}}function i(e,t){t.forEach(function(t){e._boundElements.hasOwnProperty(t.property)&&e._boundElements[t.property].forEach(function(e){e.value=t.newValue})})}function a(e,t){e.props=c.create(t,!0,function(t){e.render(),i(e,t),e._isCreated&&n(function(){o(e,t),u.callUpdate(e)})}),c.beforeChange(e.props,function(t){if(!1===u.callBeforeUpdate(e))return!1})}var c=r(14),u=r(5);e.exports={create:a}},function(e,t,r){"use strict";function n(e){return"string"==typeof e?e.replace(/&(?!\w+;)/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""):e}var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=function(){var e=[],t=[],r=[],i=null,a=function(e,t){return t.split(".").reduce(function(e,t){return e?e[t]:void 0},e||self)},c=function c(u,s,l,f){var p=l||null,d=f||"",h=[],v=function(e,t){return e instanceof Array?""!==d?d:t:""!==d?d+"."+t:t},y=function(e){if(!0!==p.paused)if(!0===s)setTimeout(function(){if(e===h.length){for(var t=0;t<p.observers.length;t++)p.observers[t](h);h=[]}},10);else{for(var t=0;t<p.observers.length;t++)p.observers[t](h);h=[]}},m={get:function(e,t){if("__getTarget"===t)return e;if("__isProxy"===t)return!0;if("__getParent"===t)return function(t){void 0===t&&(t=1);var r=v(e,"__getParent").split(".");return r.splice(-(t+1),t+1),a(p.parentProxy,r.join("."))};var r=n(e[t]);if(r instanceof Object&&null!==r&&e.hasOwnProperty(t)){!0===r.__isProxy&&(r=r.__getTarget);for(var o=-1,i=p.targets,u=0,l=i.length;u<l;u++)if(r===i[u]){o=u;break}if(o>-1)return p.proxies[o];return c(r,s,p,""!==d?d+"."+t:t)}return r},deleteProperty:function(e,n){var o=!0;i===b&&(o=!1,i=null);var a=Object.assign({},e),c=v(e,n);if(h.push({type:"delete",target:e,property:n,newValue:null,previousValue:a[n],currentPath:c,proxy:b}),"function"==typeof p.beforeChange&&p.checkBeforeChange!==c){p.checkBeforeChange=c;if(!1===p.beforeChange(h))return p.checkBeforeChange="",!1}if(p.checkBeforeChange="",!0===o){var u=void 0,s=void 0;for(u=0,s=t.length;u<s&&e!==t[u];u++);for(var l=r[u],f=l.length;f--;)l[f].proxy!==b&&(i=l[f].proxy,delete l[f].proxy[n]);delete e[n]}return y(h.length),!0},set:function(e,n,a,c){var u=!0;i===b&&(u=!1,i=null);var s=e[n];if(s!==a||!1===u){var l=void 0===s?"undefined":o(s),f=v(e,n),d="update";if("undefined"===l&&(d="add"),h.push({type:d,target:e,property:n,newValue:a,previousValue:c[n],currentPath:f,proxy:b}),"function"==typeof p.beforeChange&&p.checkBeforeChange!==f){p.checkBeforeChange=f;if(!1===p.beforeChange(h))return p.checkBeforeChange="",!1}if(p.checkBeforeChange="",!0===u){var m=void 0,g=void 0;for(m=0,g=t.length;m<g&&e!==t[m];m++);for(var E=r[m],_=0,w=E.length;_<w;_++)E[_].proxy!==b&&(i=E[_].proxy,E[_].proxy[n]=a);setTimeout(function(){if("object"===l&&null!==s){for(var n=Object.keys(e),o=0,i=n.length;o<i;o++)if(e[n[o]]===s)return;!function e(n){for(var o=Object.keys(n),i=0,a=o.length;i<a;i++){var c=n[o[i]];c instanceof Object&&null!==c&&e(c)}for(var u=-1,s=0,l=t.length;s<l;s++)if(n===t[s]){u=s;break}if(u>-1){for(var f=r[u],d=f.length;d--;)if(p===f[d].observable){f.splice(d,1);break}0===f.length&&(r.splice(u,1),t.splice(u,1))}}(s)}},1e4),e[n]=a}y(h.length)}return!0}},b=new Proxy(u,m);null===p?(p={parentTarget:u,domDelay:s,parentProxy:b,observers:[],targets:[u],proxies:[b],paused:!1,path:d},e.push(p)):(p.targets.push(u),p.proxies.push(b));for(var g={target:u,proxy:b,observable:p},E=-1,_=0,w=t.length;_<w;_++)if(u===t[_]){E=_;break}return E>-1?r[E].push(g):(t.push(u),r.push([g]),E=t.length-1),b};return{create:function(e,t,r){!0===e.__isProxy&&(e=e.__getTarget);var n=c(e,t);return"function"==typeof r&&this.observe(n,r),function e(t){for(var r=t.__getTarget,n=Object.keys(r),o=0,i=n.length;o<i;o++){var a=n[o];r[a]instanceof Object&&null!==r[a]&&e(t[a])}}(n),n},observe:function(t,r){for(var n=e.length;n--;)if(e[n].parentProxy===t){e[n].observers.push(r);break}},pause:function(t){for(var r=e.length,n=!1;r--;)if(e[r].parentProxy===t){e[r].paused=!0,n=!0;break}if(!1===n)throw new Error("ObseravableSlim could not pause observable -- matching proxy not found.")},resume:function(t){for(var r=e.length,n=!1;r--;)if(e[r].parentProxy===t){e[r].paused=!1,n=!0;break}if(!1===n)throw new Error("ObseravableSlim could not resume observable -- matching proxy not found.")},remove:function(n){for(var o=null,i=!1,a=e.length;a--;)if(e[a].parentProxy===n){o=e[a],i=!0;break}for(var c=r.length;c--;)for(var u=r[c].length;u--;)r[c][u].observable===o&&(r[c].splice(u,1),0===r[c].length&&(r.splice(c,1),t.splice(c,1)));!0===i&&e.splice(a,1)},beforeChange:function(t,r){if("function"!=typeof r)throw new Error("Callback function is required");for(var n=e.length,o=!1;n--;)if(e[n].parentProxy===t){e[n].beforeChange=r,o=!0;break}if(!1===o)throw new Error("ObseravableSlim -- matching proxy not found.")}}}();e.exports=i},function(e,t,r){"use strict";function n(e,t){return(void 0===e?"undefined":c(e))!==(void 0===t?"undefined":c(t))||"string"==typeof e&&e!==t||e.type!==t.type||e.props&&e.props.forceupdate}function o(e,t,r){if(void 0!==e){if("string"==typeof e)return document.createTextNode(e);var n=document.createElement(e.type);return s(n,e.props,t),e.children.map(function(e){return o(e,t,r)}).forEach(n.appendChild.bind(n)),-1===e.type.indexOf("-")||r||t._processing.push({node:n,action:"create"}),n}}function i(e,t,r){var c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,u=arguments[4],s=arguments[5];if(!r){var p=o(t,u,s);return e.appendChild(p),p}if(t){if(n(t,r)){var h=o(t,u,s);return e.replaceChild(h,e.childNodes[c]),h}if(t.type){var v=l(e.childNodes[c],t.props,r.props,u);if(e.childNodes[c]){var y=e.childNodes[c][d];if(y&&v.length)return void v.forEach(function(e){Object.keys(e).forEach(function(t){y.props[t]=e[t]})})}for(var m=t.children.length,b=r.children.length,g=0;g<m||g<b;g++)i(e.childNodes[c],t.children[g],r.children[g],g,u,s);a()}}else e.childNodes[c]&&f.push(e.childNodes[c])}function a(){for(var e=f.length;e--;)f[e].parentNode.removeChild(f[e]),f.splice(e,1)}var c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u=r(16),s=u.attach,l=u.updateAttributes,f=[],p=r(0),d=p.INSTANCE;e.exports={create:o,update:i}},function(e,t,r){"use strict";function n(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)}function o(e){return S.IS_LISTENER.test(e)}function i(e){return e===T.BIND}function a(e){return e===T.REF}function c(e){return-1!==["INPUT","TEXTAREA"].indexOf(e.nodeName)}function u(e,t,r,n){if(p(t));else if("className"===t)e.setAttribute("class",r);else if("boolean"==typeof r)d(e,t,r);else if("object"===(void 0===r?"undefined":_(r)))try{e.setAttribute(t,JSON.stringify(r))}catch(e){}else e.setAttribute(t,r)}function s(e,t,r){p(t)||("className"===t?e.removeAttribute("class"):"boolean"==typeof r?h(e,t):e.removeAttribute(t))}function l(e,t,r,n){r?n&&r===n||u(e,t,r):s(e,t,n)}function f(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=(arguments[3],Object.assign({},t,r)),o=[];return Object.keys(n).forEach(function(n){if(l(e,n,t[n],r[n]),t[n]!==r[n]){var i={};i[n]=t[n],o.push(i)}}),o}function p(e){return o(e)||i(e)||a(e)||"forceupdate"===e}function d(e,t,r){r?(e.setAttribute(t,r),e[t]=!0):e[t]=!1}function h(e,t){e.removeAttribute(t),e[t]=!1}function v(e){return e.slice(2).toLowerCase()}function y(e){return e.replace(S.TRIM_QUOTES,"$1")}function m(e,t,r,i){if(o(t)){var a=r.match(S.GET_LISTENER);if(i._isStatic&&(e.dataset[t]=r),a){var c=null,u=a[1],s=a[2];s&&(c=s.split(",").map(function(e){return e=e.trim(),"this"===e?i:O(y(e))}));var l=u.match(S.IS_PARENT_METHOD);l&&(u=l[1],i=i.parent);var f=C(u,i);void 0!==f&&(r=c?f.bind.apply(f,[i].concat(n(c))):f.bind(i))}"function"==typeof r&&e.addEventListener(v(t),r)}}function b(e,t,r,n){i(t)&&c(e)&&void 0!==n.props[r]&&(["compositionstart","compositionend","input","change"].forEach(function(t){e.addEventListener(t,function(){n.props[r]=this.value})}),n._boundElements.hasOwnProperty(r)?n._boundElements[r].push(e):n._boundElements[r]=[e])}function g(e,t,r,n){a(t)&&(n.ref[r]=e)}function E(e,t,r){Object.keys(t).forEach(function(n){u(e,n,t[n],r),m(e,n,t[n],r),b(e,n,t[n],r),g(e,n,t[n],r)});for(var n in e.dataset)e.dataset.hasOwnProperty(n)&&S.IS_LISTENER.test(n)&&m(e,n,e.dataset[n],r)}var _="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},w=r(0),S=w.REGEX,T=w.ATTR,O=r(7),C=r(17);e.exports={attach:E,updateAttributes:f}},function(e,t,r){"use strict";function n(e,t){return e.split(".").reduce(function(e,t){return e?e[t]:void 0},t)}function o(e,t){return-1!==e.indexOf(".")&&(e=e.split("."),e.pop(),e=e.join(".")),n(e,t)}e.exports=n,e.exports.getLast=o},function(e,t,r){"use strict";function n(e){if("string"==typeof e.store){if(void 0!==e.view._stores[e.store])throw new Error("Store already defined: "+e.store);e.view._stores[e.store]=e.props}}e.exports={create:n}},function(e,t,r){"use strict";function n(e){if("string"==typeof e.id){if(void 0!==e.view._ids[e.id])throw new Error("ID already defined: "+e.id);e.view._ids[e.id]=e}}e.exports={create:n}},function(e,t,r){"use strict";function n(e){var t={};return void 0!==e[i.ALIAS]&&(t.alias=e[i.ALIAS],delete e[i.ALIAS]),void 0!==e[i.STORE]&&(t.store=e[i.STORE],delete e[i.STORE]),void 0!==e[i.LISTENER]&&(t.callback=e[i.LISTENER],delete e[i.LISTENER]),void 0!==e[i.ID]&&(t.id=e[i.ID],delete e[i.ID]),t}var o=r(0),i=o.ATTR;e.exports={extract:n}}])}); | ||
// [DOZ] Build version: 0.0.21 | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("Doz",[],t):"object"==typeof exports?exports.Doz=t():e.Doz=t()}("undefined"!=typeof self?self:this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=10)}([function(e,t,r){"use strict";e.exports={ROOT:"__DOZ_GLOBAL_COMPONENTS__",INSTANCE:"__DOZ_INSTANCE__",TAG:{ROOT:"doz-root",EACH:"doz-each-root",VIEW:"doz-view",SUFFIX_ROOT:"-root"},REGEX:{IS_CUSTOM_TAG:/^\w+-[\w-]+$/,IS_CUSTOM_TAG_STRING:/<\w+-[\w-]+/,IS_BIND:/^d-bind$/,IS_REF:/^d-ref$/,IS_ALIAS:/^d:alias$/,IS_STORE:/^d:store$/,IS_COMPONENT_LISTENER:/^d:on-(\w+)$/,IS_LISTENER:/^on/,IS_ID_SELECTOR:/^#[\w-_:.]+$/,IS_PARENT_METHOD:/^parent.(.*)/,IS_STRING_QUOTED:/^"\w+"/,GET_LISTENER:/^this.(.*)\((.*)\)/,TRIM_QUOTES:/^["'](.*)["']$/},ATTR:{BIND:"d-bind",REF:"d-ref",ALIAS:"d:alias",STORE:"d:store",LISTENER:"d:on",ID:"d:id"}}},function(e,t,r){"use strict";function n(){return window[c]=window[c]||{components:{}},window[c].components}function o(e){var t=n(),r=e.tag.toUpperCase();if(t.hasOwnProperty(r))throw new Error("Component "+r+" already defined");t[r]=e}function i(){window[c]&&(window[c].components={})}function a(e){if("string"!=typeof e)throw new TypeError("tag must be a string");return e=e.toUpperCase(),n()[e]}var u=r(0),c=u.ROOT;e.exports={register:o,get:a,removeAll:i}},function(e,t,r){"use strict";function n(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];for(var o in t)t.hasOwnProperty(o)&&-1===r.indexOf(o)&&(e.hasOwnProperty(o)&&void 0!==e[o]?"object"===i(e[o])&&n(e[o],t[o]):e[o]=t[o]);return e}function o(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return t[0]=Object.assign({},t[0]),n.apply(this,t)}var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};e.exports=n,e.exports.copy=o},function(e,t,r){"use strict";function n(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("string"!=typeof e)throw new TypeError("Tag must be a string");if(!h.IS_CUSTOM_TAG.test(e))throw new TypeError("Tag must contain a dash (-) like my-component");var r={};r.tag=e,r.cfg=s.copy(t,{updateChildrenProps:!0,props:{},template:function(){return"<div></div>"}}),f(r)}function o(){function e(o){for(var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};o;){var u=t.autoCmp||m.get(o.nodeName)||t.view._components[o.nodeName.toLowerCase()];if(u){var c=w(o),s=C(c),l=i(u,{root:o,view:t.view,props:c,dProps:s,parentCmp:a.cmp});if(!l)continue;if(l.render(!0),r||(r=l),o.insertBefore(l._rootElement,o.firstChild),g.callRender(l),n=l,a.cmp){var f=Object.keys(a.cmp.children).length;a.cmp.children[l.alias?l.alias:f++]=l}t.autoCmp=null}o.hasChildNodes()&&e(o.firstChild,{cmp:n}),o=o.nextSibling}}var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t.template="string"==typeof t.template?p.create(t.template):t.template,t.root.appendChild(t.template);var r=null,n=void 0;return e(t.template),r}function i(e,t){var r=s.copy(t.props,"function"==typeof e.cfg.props?e.cfg.props():e.cfg.props),n=Object.defineProperties({},{_isCreated:{value:!1,writable:!0},_prevTpl:{value:null,writable:!0},_prev:{value:null,writable:!0},_prevProps:{value:null,writable:!0},_rootElement:{value:null,writable:!0},_boundElements:{value:{},writable:!0},_callback:{value:t.dProps.callback,writable:!0},_cache:{value:new Map},_loops:{value:{},writable:!0},_publicProps:{value:Object.assign({},t.props)},_processing:{value:[],writable:!0},_dynamicChildren:{value:[],writable:!0},beginSafeRender:{value:function(){I.beginRender(this.props)},enumerable:!0},endSafeRender:{value:function(){I.endRender(this.props)},enumerable:!0},view:{value:t.view,enumerable:!0},parent:{value:t.parentCmp,enumerable:!0},ref:{value:{},writable:!0,enumerable:!0},children:{value:{},writable:!0,enumerable:!0},tag:{value:e.tag,enumerable:!0},emit:{value:function(e){if(this._callback&&void 0!==this._callback[e]&&void 0!==this.parent[this._callback[e]]&&"function"==typeof this.parent[this._callback[e]]){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];this.parent[this._callback[e]].apply(this.parent,r)}},enumerable:!0},each:{value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=void 0;return Array.isArray(e)&&(r&&this.beginSafeRender(),n=e.map(t).map(function(e){if("string"==typeof e)return e.trim()}).join(""),r&&this.endSafeRender()),n},enumerable:!0},getStore:{value:function(e){return this.view.getStore(e)},enumerable:!0},getComponentById:{value:function(e){return this.view.getComponentById(e)},enumerable:!0},action:{value:t.view.action,enumerable:!0},render:{value:function(e){this.beginSafeRender();var r=this.template().trim();this.endSafeRender();var n=p.create(r,v.ROOT),o=_(n),i=S(t.root,o,this._prev,0,this,e);c(this),!this._rootElement&&i&&(this._rootElement=i),this._prev=o},enumerable:!0},mount:{value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this._rootElement;return"string"==typeof t.selector?r=r.querySelector(t.selector):t.selector instanceof HTMLElement&&(r=t.selector),this.view.mount(e,r,this)},enumerable:!0},destroy:{value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];(t||this._rootElement&&!1!==g.callBeforeDestroy(this)&&this._rootElement.parentNode)&&(Object.keys(this.children).forEach(function(t){e.children[t].destroy()}),t?this._rootElement.parentNode.innerHTML="":this._rootElement.parentNode.parentNode.removeChild(this._rootElement.parentNode),g.callDestroy(this))},enumerable:!0}});if(a(n,e.cfg,t.dProps),!1!==g.callBeforeCreate(n))return b.create(n,r),T.create(n),O.create(n),g.callCreate(n),n._isCreated=!0,n}function a(e,t,r){Object.assign(e,t,r)}function u(e){for(var t=e._dynamicChildren.length-1;t>=0;){var r=e._dynamicChildren[t];!document.body.contains(r)&&r[y]&&(r[y].destroy(!0),e._dynamicChildren.splice(t,1)),t-=1}}function c(e){u(e);for(var t=e._processing.length-1;t>=0;){var r=e._processing[t],n=r.node.parentNode;r.node[y]&&r.node[y].destroy(!0);var i=o({root:n,template:r.node.outerHTML,view:e.view});e._dynamicChildren.push(i._rootElement.parentNode),n.replaceChild(i._rootElement.parentNode,r.node),i._rootElement.parentNode[y]=i,e._processing.splice(t,1),t-=1}}var s=r(2),l=r(1),f=l.register,p=r(4),d=r(0),h=d.REGEX,v=d.TAG,y=d.INSTANCE,m=r(1),b=r(14),g=r(6),E=r(7),_=E.transform,w=E.serializeProps,S=r(9).updateElement,T=r(18),O=r(19),x=r(20),C=x.extract,I=r(5);e.exports={component:n,getInstances:o}},function(e,t,r){"use strict";var n=/\n/g,o=/\s+/g,i={create:function(e,t){var r=void 0;e=e.replace(n," "),e=e.replace(o," ");var i=document.createElement("div");if(i.innerHTML=e,i.childNodes.length>1?(r=document.createElement(t),r.innerHTML=i.innerHTML):r=i.firstChild||document.createTextNode(""),!this.isValidNode(r))throw new Error("Element not valid");return r},isValidNode:function(e){return e&&"nodeType"in e},getAllNodes:function(e){function t(e){for(;e;)r.push(e),e.hasChildNodes()&&t(e.firstChild),e=e.nextSibling}var r=[];return t(e),r}};e.exports=i},function(e,t,r){"use strict";function n(e){return"string"==typeof e?e.replace(/&(?!\w+;)/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""):e}var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=function(){var e=[],t=[],r=[],i=null,a=function(e,t){return t.split(".").reduce(function(e,t){return e?e[t]:void 0},e||self)},u=function u(c,s,l,f){var p=l||null,d=f||"",h=[],v=function(e,t){return e instanceof Array?""!==d?d:t:""!==d?d+"."+t:t},y=function(e){if(!0!==p.paused)if(!0===s)setTimeout(function(){if(e===h.length){for(var t=0;t<p.observers.length;t++)p.observers[t](h);h=[]}},10);else{for(var t=0;t<p.observers.length;t++)p.observers[t](h);h=[]}},m={get:function(e,t){if("__getTarget"===t)return e;if("__isProxy"===t)return!0;if("__getParent"===t)return function(t){void 0===t&&(t=1);var r=v(e,"__getParent").split(".");return r.splice(-(t+1),t+1),a(p.parentProxy,r.join("."))};var r=e[t];if(r instanceof Object&&null!==r&&e.hasOwnProperty(t)){!0===r.__isProxy&&(r=r.__getTarget);for(var o=-1,i=p.targets,c=0,l=i.length;c<l;c++)if(r===i[c]){o=c;break}if(o>-1)return p.proxies[o];return u(r,s,p,""!==d?d+"."+t:t)}return p.renderMode?n(r):r},deleteProperty:function(e,n){var o=!0;i===b&&(o=!1,i=null);var a=Object.assign({},e),u=v(e,n);if(h.push({type:"delete",target:e,property:n,newValue:null,previousValue:a[n],currentPath:u,proxy:b}),"function"==typeof p.beforeChange&&p.checkBeforeChange!==u){p.checkBeforeChange=u;if(!1===p.beforeChange(h))return p.checkBeforeChange="",!1}if(p.checkBeforeChange="",!0===o){var c=void 0,s=void 0;for(c=0,s=t.length;c<s&&e!==t[c];c++);for(var l=r[c],f=l.length;f--;)l[f].proxy!==b&&(i=l[f].proxy,delete l[f].proxy[n]);delete e[n]}return y(h.length),!0},set:function(e,n,a,u){var c=!0;i===b&&(c=!1,i=null);var s=e[n];if(s!==a||!1===c){var l=void 0===s?"undefined":o(s),f=v(e,n),d="update";if("undefined"===l&&(d="add"),h.push({type:d,target:e,property:n,newValue:a,previousValue:u[n],currentPath:f,proxy:b}),"function"==typeof p.beforeChange&&p.checkBeforeChange!==f){p.checkBeforeChange=f;if(!1===p.beforeChange(h))return p.checkBeforeChange="",!1}if(p.checkBeforeChange="",!0===c){var m=void 0,g=void 0;for(m=0,g=t.length;m<g&&e!==t[m];m++);var E=r[m];if(E)for(var _=0,w=E.length;_<w;_++)E[_].proxy!==b&&(i=E[_].proxy,E[_].proxy[n]=a);setTimeout(function(){if("object"===l&&null!==s){for(var n=Object.keys(e),o=0,i=n.length;o<i;o++)if(e[n[o]]===s)return;!function e(n){for(var o=Object.keys(n),i=0,a=o.length;i<a;i++){var u=n[o[i]];u instanceof Object&&null!==u&&e(u)}for(var c=-1,s=0,l=t.length;s<l;s++)if(n===t[s]){c=s;break}if(c>-1){for(var f=r[c],d=f.length;d--;)if(p===f[d].observable){f.splice(d,1);break}0===f.length&&(r.splice(c,1),t.splice(c,1))}}(s)}},1e4),e[n]=a}y(h.length)}return!0}},b=new Proxy(c,m);null===p?(p={parentTarget:c,domDelay:s,parentProxy:b,observers:[],targets:[c],proxies:[b],paused:!1,path:d},e.push(p)):(p.targets.push(c),p.proxies.push(b));for(var g={target:c,proxy:b,observable:p},E=-1,_=0,w=t.length;_<w;_++)if(c===t[_]){E=_;break}return E>-1?r[E].push(g):(t.push(c),r.push([g]),E=t.length-1),b};return{create:function(e,t,r){!0===e.__isProxy&&(e=e.__getTarget);var n=u(e,t);return"function"==typeof r&&this.observe(n,r),function e(t){for(var r=t.__getTarget,n=Object.keys(r),o=0,i=n.length;o<i;o++){var a=n[o];r[a]instanceof Object&&null!==r[a]&&e(t[a])}}(n),n},observe:function(t,r){for(var n=e.length;n--;)if(e[n].parentProxy===t){e[n].observers.push(r);break}},pause:function(t){for(var r=e.length,n=!1;r--;)if(e[r].parentProxy===t){e[r].paused=!0,n=!0;break}if(!1===n)throw new Error("ObseravableSlim could not pause observable -- matching proxy not found.")},resume:function(t){for(var r=e.length,n=!1;r--;)if(e[r].parentProxy===t){e[r].paused=!1,n=!0;break}if(!1===n)throw new Error("ObseravableSlim could not resume observable -- matching proxy not found.")},remove:function(n){for(var o=null,i=!1,a=e.length;a--;)if(e[a].parentProxy===n){o=e[a],i=!0;break}for(var u=r.length;u--;)for(var c=r[u].length;c--;)r[u][c].observable===o&&(r[u].splice(c,1),0===r[u].length&&(r.splice(u,1),t.splice(u,1)));!0===i&&e.splice(a,1)},beforeChange:function(t,r){if("function"!=typeof r)throw new Error("Callback function is required");for(var n=e.length,o=!1;n--;)if(e[n].parentProxy===t){e[n].beforeChange=r,o=!0;break}if(!1===o)throw new Error("ObseravableSlim -- matching proxy not found.")},beginRender:function(t){for(var r=e.length,n=!1;r--;)if(e[r].parentProxy===t){e[r].renderMode=!0,n=!0;break}if(!1===n)throw new Error("ObseravableSlim -- matching proxy not found.")},endRender:function(t){for(var r=e.length,n=!1;r--;)if(e[r].parentProxy===t){e[r].renderMode=!1,n=!0;break}if(!1===n)throw new Error("ObseravableSlim -- matching proxy not found.")}}}();e.exports=i},function(e,t,r){"use strict";function n(e){if("function"==typeof e.onBeforeCreate)return e.onBeforeCreate.call(e)}function o(e){"function"==typeof e.onCreate&&e.onCreate.call(e)}function i(e){"function"==typeof e.onRender&&e.onRender.call(e)}function a(e){if("function"==typeof e.onBeforeUpdate)return e.onBeforeUpdate.call(e,Object.assign({},e.props))}function u(e){"function"==typeof e.onUpdate&&e.onUpdate.call(e)}function c(e){if("function"==typeof e.onBeforeDestroy)return e.onBeforeDestroy.call(e)}function s(e){"function"==typeof e.onDestroy&&(e.onDestroy.call(e),e=null)}e.exports={callBeforeCreate:n,callCreate:o,callRender:i,callBeforeUpdate:a,callUpdate:u,callBeforeDestroy:c,callDestroy:s}},function(e,t,r){"use strict";function n(e){var t={};if(e.attributes)for(var r=Array.from(e.attributes),n=r.length-1;n>=0;--n){var o=r[n],a=o.name.match(u.IS_COMPONENT_LISTENER);if(a)void 0===t[c.LISTENER]&&(t[c.LISTENER]={}),t[c.LISTENER][a[1]]=o.nodeValue,delete t[o.name];else{var s=o.nodeValue;u.IS_STRING_QUOTED.test(s)&&(s=o.nodeValue.replace(/"/g,""")),t[o.name]=""===s||i(s)}}return t}function o(e){function t(e,o){for(;e;){var i=void 0;3===e.nodeType?i=e.nodeValue:(i={},i.type=e.nodeName.toLowerCase(),i.children=[],i.props=n(e)),Object.keys(r).length||(r=i),o&&o.children&&o.children.push(i),e.hasChildNodes()&&t(e.firstChild,i),e=e.nextSibling}}var r={};return t(e,r),r}var i=r(8),a=r(0),u=a.REGEX,c=a.ATTR;e.exports={transform:o,serializeProps:n}},function(e,t,r){"use strict";function n(e){if("string"!=typeof e)return e;switch(e){case"undefined":return;case"null":return null;case"NaN":return NaN;case"Infinity":return 1/0;case"true":return!0;case"false":return!1;case"0":return e;default:try{return JSON.parse(e)}catch(e){}}var t=parseFloat(e);return!isNaN(t)&&isFinite(e)?0===e.toLowerCase().indexOf("0x")?parseInt(e,16):t:e}e.exports=n},function(e,t,r){"use strict";var n=r(15);e.exports={updateElement:n.update}},function(e,t,r){"use strict";e.exports=r(11)},function(e,t,r){"use strict";e.exports=r(12),e.exports.component=r(3).component,e.exports.collection=r(1),e.exports.update=r(9).updateElement,e.exports.transform=r(7).transform,e.exports.html=r(4)},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),a=r(2),u=r(13),c=r(3),s=r(0),l=s.TAG,f=s.REGEX,p=function(){function e(){var t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};n(this,e);var i="<"+l.VIEW+"></"+l.VIEW+">";if(f.IS_ID_SELECTOR.test(r.root)&&(r.root=document.getElementById(r.root.substring(1))),f.IS_ID_SELECTOR.test(r.template)&&(r.template=document.getElementById(r.template.substring(1)),r.template=r.template.innerHTML),!(r.root instanceof HTMLElement))throw new TypeError("root must be an HTMLElement or an valid ID selector like #example-root");if(!(r.template instanceof HTMLElement||"string"==typeof r.template||"function"==typeof r.template))throw new TypeError("template must be a string or an HTMLElement or a function or an valid ID selector like #example-template");this.cfg=a(r,{components:[],actions:{}}),Object.defineProperties(this,{_components:{value:{},writable:!0},_usedComponents:{value:{},writable:!0},_stores:{value:{},writable:!0},_cache:{value:new Map},_ids:{value:{},writable:!0},action:{value:u(this.cfg.actions,this),enumerable:!0},mount:{value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this._tree;if("string"==typeof t&&(t=document.querySelector(t)),!((t=t||r._rootElement)instanceof HTMLElement))throw new TypeError("root must be an HTMLElement or an valid selector like #example-root");var n={tag:l.ROOT,cfg:{props:{},template:function(){return e}}};return c.getInstances({root:t,template:"<"+l.ROOT+"></"+l.ROOT+">",view:this,parentCmp:r,autoCmp:n,mount:!0})},enumerable:!0}}),this.cfg.components.forEach(function(e){"object"===(void 0===e?"undefined":o(e))&&"string"==typeof e.tag&&"object"===o(e.cfg)&&(t._components[e.tag]=e)}),this._components[l.VIEW]={tag:l.VIEW,cfg:{props:r.props||{},template:function(){return"function"==typeof r.template?r.template():r.template}}},this._tree=c.getInstances({root:this.cfg.root,template:i,view:this})||[]}return i(e,[{key:"getComponent",value:function(e){return this._tree?this._tree.children[e]:void 0}},{key:"getComponentById",value:function(e){return this._ids[e]}},{key:"getStore",value:function(e){return this._stores[e]}}]),e}();e.exports=p},function(e,t,r){"use strict";function n(e,t){if("object"!==(void 0===e?"undefined":o(e)))throw new TypeError("expected an object");for(var r=Object.assign({},e),i=Object.keys(e),a=i.length-1;a>=0;--a){var u=r[i[a]];"function"==typeof u?r[i[a]]=u.bind(t):"object"===(void 0===u?"undefined":o(u))&&(r[i[a]]=n(u,t))}return r}var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};e.exports=n},function(e,t,r){"use strict";function n(e){return void 0!==window.requestAnimationFrame?window.requestAnimationFrame(e):window.setTimeout(e)}function o(e,t){if(e.updateChildrenProps){Object.keys(e.children).forEach(function(r){t.forEach(function(t){e.children[r]._publicProps.hasOwnProperty(t.currentPath)&&e.children[r].props.hasOwnProperty(t.currentPath)&&(e.children[r].props[t.currentPath]=t.newValue)})})}}function i(e,t){t.forEach(function(t){e._boundElements.hasOwnProperty(t.property)&&e._boundElements[t.property].forEach(function(e){e.value=t.newValue})})}function a(e,t){e.props=u.create(t,!0,function(t){e.render(),i(e,t),e._isCreated&&n(function(){o(e,t),c.callUpdate(e)})}),u.beforeChange(e.props,function(t){if(!1===c.callBeforeUpdate(e))return!1})}var u=r(5),c=r(6);e.exports={create:a}},function(e,t,r){"use strict";function n(e,t){return(void 0===e?"undefined":u(e))!==(void 0===t?"undefined":u(t))||"string"==typeof e&&e!==t||e.type!==t.type||e.props&&e.props.forceupdate}function o(e,t,r){if(void 0!==e){if("string"==typeof e)return document.createTextNode(e);var n=document.createElement(e.type);return s(n,e.props,t),e.children.map(function(e){return o(e,t,r)}).forEach(n.appendChild.bind(n)),-1===e.type.indexOf("-")||r||t._processing.push({node:n,action:"create"}),n}}function i(e,t,r){var u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,c=arguments[4],s=arguments[5];if(!r){var p=o(t,c,s);return e.appendChild(p),p}if(t){if(n(t,r)){var h=o(t,c,s);return e.replaceChild(h,e.childNodes[u]),h}if(t.type){var v=l(e.childNodes[u],t.props,r.props,c);if(e.childNodes[u]){var y=e.childNodes[u][d];if(y&&v.length)return void v.forEach(function(e){Object.keys(e).forEach(function(t){y.props[t]=e[t]})})}for(var m=t.children.length,b=r.children.length,g=0;g<m||g<b;g++)i(e.childNodes[u],t.children[g],r.children[g],g,c,s);a()}}else e.childNodes[u]&&f.push(e.childNodes[u])}function a(){for(var e=f.length;e--;)f[e].parentNode.removeChild(f[e]),f.splice(e,1)}var u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c=r(16),s=c.attach,l=c.updateAttributes,f=[],p=r(0),d=p.INSTANCE;e.exports={create:o,update:i}},function(e,t,r){"use strict";function n(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)}function o(e){return S.IS_LISTENER.test(e)}function i(e){return e===T.BIND}function a(e){return e===T.REF}function u(e){return-1!==["INPUT","TEXTAREA"].indexOf(e.nodeName)}function c(e,t,r,n){if(p(t));else if("className"===t)e.setAttribute("class",r);else if("boolean"==typeof r)d(e,t,r);else if("object"===(void 0===r?"undefined":_(r)))try{e.setAttribute(t,JSON.stringify(r))}catch(e){}else e.setAttribute(t,r)}function s(e,t,r){p(t)||("className"===t?e.removeAttribute("class"):"boolean"==typeof r?h(e,t):e.removeAttribute(t))}function l(e,t,r,n){r?n&&r===n||c(e,t,r):s(e,t,n)}function f(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=(arguments[3],Object.assign({},t,r)),o=[];return Object.keys(n).forEach(function(n){if(l(e,n,t[n],r[n]),t[n]!==r[n]){var i={};i[n]=t[n],o.push(i)}}),o}function p(e){return o(e)||i(e)||a(e)||"forceupdate"===e}function d(e,t,r){r?(e.setAttribute(t,r),e[t]=!0):e[t]=!1}function h(e,t){e.removeAttribute(t),e[t]=!1}function v(e){return e.slice(2).toLowerCase()}function y(e){return e.replace(S.TRIM_QUOTES,"$1")}function m(e,t,r,i){if(o(t)){var a=r.match(S.GET_LISTENER);if(a){var u=null,c=a[1],s=a[2];s&&(u=s.split(",").map(function(e){return e=e.trim(),"this"===e?i:O(y(e))}));var l=c.match(S.IS_PARENT_METHOD);l&&(c=l[1],i=i.parent);var f=x(c,i);void 0!==f&&(r=u?f.bind.apply(f,[i].concat(n(u))):f.bind(i))}"function"==typeof r&&e.addEventListener(v(t),r)}}function b(e,t,r,n){i(t)&&u(e)&&void 0!==n.props[r]&&(["compositionstart","compositionend","input","change"].forEach(function(t){e.addEventListener(t,function(){n.props[r]=this.value})}),n._boundElements.hasOwnProperty(r)?n._boundElements[r].push(e):n._boundElements[r]=[e])}function g(e,t,r,n){a(t)&&(n.ref[r]=e)}function E(e,t,r){Object.keys(t).forEach(function(n){c(e,n,t[n],r),m(e,n,t[n],r),b(e,n,t[n],r),g(e,n,t[n],r)});for(var n in e.dataset)e.dataset.hasOwnProperty(n)&&S.IS_LISTENER.test(n)&&m(e,n,e.dataset[n],r)}var _="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},w=r(0),S=w.REGEX,T=w.ATTR,O=r(8),x=r(17);e.exports={attach:E,updateAttributes:f}},function(e,t,r){"use strict";function n(e,t){return e.split(".").reduce(function(e,t){return e?e[t]:void 0},t)}function o(e,t){return-1!==e.indexOf(".")&&(e=e.split("."),e.pop(),e=e.join(".")),n(e,t)}e.exports=n,e.exports.getLast=o},function(e,t,r){"use strict";function n(e){if("string"==typeof e.store){if(void 0!==e.view._stores[e.store])throw new Error("Store already defined: "+e.store);e.view._stores[e.store]=e.props}}e.exports={create:n}},function(e,t,r){"use strict";function n(e){if("string"==typeof e.id){if(void 0!==e.view._ids[e.id])throw new Error("ID already defined: "+e.id);e.view._ids[e.id]=e}}e.exports={create:n}},function(e,t,r){"use strict";function n(e){var t={};return void 0!==e[i.ALIAS]&&(t.alias=e[i.ALIAS],delete e[i.ALIAS]),void 0!==e[i.STORE]&&(t.store=e[i.STORE],delete e[i.STORE]),void 0!==e[i.LISTENER]&&(t.callback=e[i.LISTENER],delete e[i.LISTENER]),void 0!==e[i.ID]&&(t.id=e[i.ID],delete e[i.ID]),t}var o=r(0),i=o.ATTR;e.exports={extract:n}}])}); |
@@ -161,5 +161,7 @@ <div align="center"> | ||
| `children` | object | An object that contains all children components | no | no | | ||
| `beginSafeRender` | function | This method enable encoding of props into HTML entities before they are called | no | no | | ||
| `destroy` | function | Destroy component and his children | no | no | | ||
| `each` | function | This method serves to iterate parts of the template. More info on [loops](#loops) | no | no | | ||
| `emit` | function | This method call a callback given an event name. More info on [emitter](#emitter) | no | no | | ||
| `endSafeRender` | function | This method disable encoding of props into HTML entities before they are called | no | no | | ||
| `getComponent` | function | Get child component by alias | no | yes | | ||
@@ -523,3 +525,3 @@ | `getComponentById` | function | Get component by id | no | no | | ||
##### d:id | ||
This attribute allow you to define an unique name that identify the component globally. | ||
This attribute allows you to define an unique name that identify the component globally. | ||
@@ -561,3 +563,3 @@ ```javascript | ||
##### d:store | ||
This attribute allow you to define an unique name that expose your component props globally. | ||
This attribute allows you to define an unique name that expose your component props globally. | ||
@@ -602,3 +604,3 @@ ```javascript | ||
##### d:on | ||
This attribute allow you to define an event name. | ||
This attribute allows you to define an event name. | ||
@@ -676,3 +678,3 @@ ```javascript | ||
### Loops | ||
Same situation as conditional statements but using the method `each` provided by component: | ||
Same situation like conditional statements but using the method `each` provided by component: | ||
@@ -717,3 +719,3 @@ ```javascript | ||
### Actions | ||
The actions allow to better organize the logic of the various components in the view, | ||
The actions allows to better organize the logic of the various components in the view, | ||
and they are global so can be called in all components. | ||
@@ -720,0 +722,0 @@ |
{ | ||
"name": "doz", | ||
"version": "0.0.20", | ||
"version": "0.0.21", | ||
"description": "A JavaScript framework for building UI, almost like writing in VanillaJS.", | ||
@@ -5,0 +5,0 @@ "main": "dist/doz.js", |
@@ -13,2 +13,3 @@ const extend = require('../utils/extend'); | ||
const {extract} = require('./d-props'); | ||
const proxy = require('../utils/proxy'); | ||
@@ -66,4 +67,4 @@ function component(tag, cfg = {}) { | ||
dProps, | ||
parentCmp: parent.cmp, | ||
isStatic: cfg.isStatic | ||
parentCmp: parent.cmp/*, | ||
isStatic: cfg.isStatic*/ | ||
}); | ||
@@ -149,5 +150,5 @@ | ||
}, | ||
_isStatic: { | ||
/*_isStatic: { | ||
value: cfg.isStatic | ||
}, | ||
},*/ | ||
_publicProps: { | ||
@@ -164,2 +165,14 @@ value: Object.assign({}, cfg.props) | ||
}, | ||
beginSafeRender: { | ||
value: function () { | ||
proxy.beginRender(this.props) | ||
}, | ||
enumerable: true | ||
}, | ||
endSafeRender: { | ||
value: function () { | ||
proxy.endRender(this.props) | ||
}, | ||
enumerable: true | ||
}, | ||
view: { | ||
@@ -198,9 +211,14 @@ value: cfg.view, | ||
each: { | ||
value: function (obj, func) { | ||
value: function (obj, func, safe = false) { | ||
let res; | ||
if (Array.isArray(obj)) { | ||
return obj.map(func).map(stringEl => { | ||
stringEl = stringEl.trim(); | ||
return stringEl | ||
if (safe) this.beginSafeRender(); | ||
res = obj.map(func).map(stringEl => { | ||
if (typeof stringEl === 'string') { | ||
return stringEl.trim() | ||
} | ||
}).join(''); | ||
if (safe) this.endSafeRender(); | ||
} | ||
return res; | ||
}, | ||
@@ -227,3 +245,6 @@ enumerable: true | ||
value: function (initial) { | ||
this.beginSafeRender(); | ||
const template = this.template().trim(); | ||
this.endSafeRender(); | ||
const tpl = html.create(template, TAG.ROOT); | ||
@@ -230,0 +251,0 @@ let next = transform(tpl); |
@@ -70,3 +70,2 @@ const extend = require('./utils/extend'); | ||
//console.log('ROOT', root.innerHTML); | ||
const autoCmp = { | ||
@@ -87,3 +86,3 @@ tag: TAG.ROOT, | ||
parentCmp: parent, | ||
isStatic: false, | ||
//isStatic: false, | ||
autoCmp, | ||
@@ -90,0 +89,0 @@ mount: true |
@@ -118,3 +118,3 @@ /* | ||
// for performance improvements, we assign this to a variable so we do not have to lookup the property value again | ||
let targetProp = sanitize(target[property]); | ||
let targetProp = target[property]; | ||
@@ -147,3 +147,3 @@ // if we are traversing into a new object, then we want to record path to that object and return a new observable. | ||
} else { | ||
return targetProp; | ||
return observable.renderMode ? sanitize(targetProp) : targetProp; | ||
} | ||
@@ -275,16 +275,17 @@ }, | ||
let currentTargetProxy = targetsProxy[a]; | ||
for (let b = 0, l = currentTargetProxy.length; b < l; b++) { | ||
// if the same target has a different proxy | ||
if (currentTargetProxy[b].proxy !== proxy) { | ||
if (currentTargetProxy) | ||
for (let b = 0, l = currentTargetProxy.length; b < l; b++) { | ||
// if the same target has a different proxy | ||
if (currentTargetProxy[b].proxy !== proxy) { | ||
// !!IMPORTANT!! store the proxy as a duplicate proxy (dupProxy) -- this will adjust the behavior above appropriately (that is, | ||
// prevent a change on dupProxy from re-triggering the same change on other proxies) | ||
dupProxy = currentTargetProxy[b].proxy; | ||
// !!IMPORTANT!! store the proxy as a duplicate proxy (dupProxy) -- this will adjust the behavior above appropriately (that is, | ||
// prevent a change on dupProxy from re-triggering the same change on other proxies) | ||
dupProxy = currentTargetProxy[b].proxy; | ||
// invoke the same change on the different proxy for the same target object. it is important that we make this change *after* we invoke the same change | ||
// on any other proxies so that the previousValue can show up correct for the other proxies | ||
currentTargetProxy[b].proxy[property] = value; | ||
// invoke the same change on the different proxy for the same target object. it is important that we make this change *after* we invoke the same change | ||
// on any other proxies so that the previousValue can show up correct for the other proxies | ||
currentTargetProxy[b].proxy[property] = value; | ||
} | ||
} | ||
} | ||
@@ -406,3 +407,3 @@ // if the property being overwritten is an object, then that means this observable | ||
// store the proxy we've created so it isn't re-created unnecessairly via get handler | ||
// store the proxy we've created so it isn't re-created unnecessary via get handler | ||
let proxyItem = {target, proxy, observable}; | ||
@@ -581,2 +582,38 @@ | ||
if (foundMatch === false) throw new Error('ObseravableSlim -- matching proxy not found.'); | ||
}, | ||
/** | ||
* beginRender | ||
* @description This method set renderMode to true so the param in get is sanitized. | ||
* @param proxy {Proxy} the ES6 Proxy returned by the create() method. | ||
*/ | ||
beginRender: function (proxy) { | ||
let i = observables.length; | ||
let foundMatch = false; | ||
while (i--) { | ||
if (observables[i].parentProxy === proxy) { | ||
observables[i].renderMode = true; | ||
foundMatch = true; | ||
break; | ||
} | ||
} | ||
if (foundMatch === false) throw new Error('ObseravableSlim -- matching proxy not found.'); | ||
}, | ||
/** | ||
* endRender | ||
* @description This method set renderMode to false. | ||
* @param proxy {Proxy} the ES6 Proxy returned by the create() method. | ||
*/ | ||
endRender: function (proxy) { | ||
let i = observables.length; | ||
let foundMatch = false; | ||
while (i--) { | ||
if (observables[i].parentProxy === proxy) { | ||
observables[i].renderMode = false; | ||
foundMatch = true; | ||
break; | ||
} | ||
} | ||
if (foundMatch === false) throw new Error('ObseravableSlim -- matching proxy not found.'); | ||
} | ||
@@ -583,0 +620,0 @@ }; |
@@ -109,4 +109,4 @@ const {REGEX, ATTR} = require('../constants'); | ||
// Add only if is a static component | ||
if (cmp._isStatic) | ||
$target.dataset[name] = value; | ||
/*if (cmp._isStatic) | ||
$target.dataset[name] = value;*/ | ||
@@ -113,0 +113,0 @@ if (match) { |
@@ -71,7 +71,2 @@ const {attach, updateAttributes} = require('./attributes'); | ||
/*if (newNode.props[ATTR.DYNAMIC] && updated.length) { | ||
cmp._processing.push({node: $parent.childNodes[index], action: 'update'}); | ||
return; | ||
}*/ | ||
const newLength = newNode.children.length; | ||
@@ -78,0 +73,0 @@ const oldLength = oldNode.children.length; |
Sorry, the diff of this file is too big to display
194623
3498
30