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

deku

Package Overview
Dependencies
Maintainers
1
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deku - npm Package Compare versions

Comparing version 0.0.17 to 0.0.18

perf/runner.html

2

bower.json
{
"name": "deku",
"version": "0.0.17",
"version": "0.0.18",
"main": "dist/deku.js"
}
{
"name": "deku",
"version": "0.0.17",
"version": "0.0.18",
"dependencies": {

@@ -5,0 +5,0 @@ "component/each": "0.2.5",

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

!function(t){"object"==typeof exports?module.exports=t("1"):"function"==typeof define&&define.amd?define(function(){return t("1")}):this.deku=t("1")}(function t(e,n,r){function o(t){if(n[t])return n[t].exports;if(e[t])return i(t,o);throw new Error('cannot find module "'+t+'"')}function i(o,i){var s=n[o]={exports:{}},a=e[o],c=a[2],u=a[0];return u.call(s.exports,function(t){var n=e[o][1][t];return i(n?n:t)},s,s.exports,t,e,n,r),c&&(n[c]=n[o]),n[o].exports}var s=function(){return this}();for(var a in r)r[a]?s[r[a]]=o(a):o(a);return o.duo=!0,o.cache=n,o.modules=e,o}({1:[function(t,e,n){n.component=t("./lib/component"),n.dom=t("./lib/virtual").node},{"./lib/component":2,"./lib/virtual":3}],2:[function(t,e){function n(t){function e(){return this instanceof e?void o(this):c(e,arguments[0],arguments[1])}if(t=t||{},"function"==typeof t&&(t={render:t}),e.props={},e.channels=[],r(e,s,i.prototype),r(e.prototype,a,t,i.prototype),t.displayName&&(e.displayName=t.displayName,delete t.displayName),t.props){for(var n in t.props)e.prop(n,t.props[n]);delete t.props}return t.channels&&(t.channels.forEach(function(t){e.channel(t)}),delete t.channels),e}var r=t("sindresorhus/object-assign"),o=t("segmentio/bind-all"),i=t("component/emitter"),s=t("./statics"),a=t("./protos"),c=t("../virtual").node;e.exports=n},{"sindresorhus/object-assign":4,"segmentio/bind-all":5,"component/emitter":6,"./statics":7,"./protos":8,"../virtual":3}],4:[function(t,e){"use strict";function n(t){if(null==t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}e.exports=Object.assign||function(t){for(var e,r,o,i=n(t),s=1;s<arguments.length;s++){r=arguments[s],o=Object.keys(Object(r));for(var a=0;a<o.length;a++)try{i[o[a]]=r[o[a]]}catch(c){void 0===e&&(e=c)}}if(e)throw e;return i}},{}],5:[function(t,e){try{var n=t("bind"),r=t("type")}catch(o){var n=t("bind-component"),r=t("type-component")}e.exports=function(t){for(var e in t){var o=t[e];"function"===r(o)&&(t[e]=n(t,t[e]))}return t}},{bind:9,type:10}],9:[function(t,e){var n=[].slice;e.exports=function(t,e){if("string"==typeof e&&(e=t[e]),"function"!=typeof e)throw new Error("bind() requires a function");var r=n.call(arguments,2);return function(){return e.apply(t,r.concat(n.call(arguments)))}}},{}],10:[function(t,e){var n=Object.prototype.toString;e.exports=function(t){switch(n.call(t)){case"[object Date]":return"date";case"[object RegExp]":return"regexp";case"[object Arguments]":return"arguments";case"[object Array]":return"array";case"[object Error]":return"error"}return null===t?"null":void 0===t?"undefined":t!==t?"nan":t&&1===t.nodeType?"element":(t=t.valueOf?t.valueOf():Object.prototype.valueOf.apply(t),typeof t)}},{}],6:[function(t,e){function n(t){return t?r(t):void 0}function r(t){for(var e in n.prototype)t[e]=n.prototype[e];return t}e.exports=n,n.prototype.on=n.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks[t]=this._callbacks[t]||[]).push(e),this},n.prototype.once=function(t,e){function n(){r.off(t,n),e.apply(this,arguments)}var r=this;return this._callbacks=this._callbacks||{},n.fn=e,this.on(t,n),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n=this._callbacks[t];if(!n)return this;if(1==arguments.length)return delete this._callbacks[t],this;for(var r,o=0;o<n.length;o++)if(r=n[o],r===e||r.fn===e){n.splice(o,1);break}return this},n.prototype.emit=function(t){this._callbacks=this._callbacks||{};var e=[].slice.call(arguments,1),n=this._callbacks[t];if(n){n=n.slice(0);for(var r=0,o=n.length;o>r;++r)n[r].apply(this,e)}return this},n.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks[t]||[]},n.prototype.hasListeners=function(t){return!!this.listeners(t).length}},{}],7:[function(t,e,n){var r=t("../renderer/string"),o=t("../entity"),i=t("../scene");if("undefined"!=typeof window)var s=t("../renderer/html");n.use=function(t){if("function"==typeof t)t(this);else for(var e in t)this.prototype[e]=t[e];return this},n.prop=function(t,e){return this.props[t]=e,this},n.channel=function(t){return this.channels.push(t),this},n.render=function(t,e){if(!s)throw new Error("You can only render a DOM tree in the browser. Use renderString instead.");var n=new s(t),r=new o(this,e),a=new i(n,r);return a},n.renderString=function(t){var e=new o(this,t);return r(e)}},{"../renderer/string":11,"../entity":12,"../scene":13,"../renderer/html":14}],11:[function(t,e){function n(t){var e=t.render();return r(e.root,e)}function r(t,e){e.getPath(t);if("text"===t.type)return t.data;if("element"===t.type){for(var i=t.children,a=t.attributes,c=t.tagName,u="<"+c+o(a)+">",p=0,h=i.length;h>p;p++)u+=r(i[p],e);return u+="</"+c+">"}if("component"===t.type)return n(new s(t.component,t.props));throw new Error("Invalid type")}function o(t){var e="";for(var n in t)e+=i(n,t[n]);return e}function i(t,e){return" "+t+'="'+e+'"'}var s=(t("../../virtual"),t("../../entity"));e.exports=n},{"../../virtual":3,"../../entity":12}],3:[function(t,e,n){function r(t,e,n){2!==arguments.length||"string"!=typeof e&&!Array.isArray(e)||(n=e,e={}),n=n||[],e=e||{},Array.isArray(n)||(n=[n]),n=n.map(o);var r=e.key;delete e.key;var a;return a="function"==typeof t?i(t,e,r,n):s(t,e,r,n),a.id=(++u).toString(32),a}function o(t,e){if(("string"==typeof t||"number"==typeof t)&&(t=a(String(t))),Array.isArray(t))throw new Error("Child node cant be an array. This can happen if you try to use props.children like a node.");return t.index=e,t}var i=t("./component"),s=t("./element"),a=t("./text"),c=t("./tree");n.node=r,n.tree=c;var u=0},{"./component":15,"./element":16,"./text":17,"./tree":18}],15:[function(t,e){e.exports=function(t,e,n,r){var o={};return o.key=n,o.props=e,o.type="component",o.component=t,o.props.children=r||[],o}},{}],16:[function(t,e){function n(t){t.style&&(t.style=r(t.style)),t.data&&(t=o(t)),t["class"]&&(t["class"]=i(t["class"]));for(var e in t)t[e]===!1&&delete t[e];return t}function r(t){if("object"!==c(t))return t;var e="";for(var n in t){var r=t[n];e+=n+":"+r+";"}return e}function o(t){if("object"!==c(t.data))return t;for(var e in t.data)t["data-"+e]=t.data[e];return delete t.data,t}function i(t){if("object"===c(t)){var e=[];for(var n in t)t[n]&&e.push(n);t=e}if("array"===c(t)){if(0===t.length)return;t=t.join(" ")}return t}function s(t){var e={};for(var n in u){var r=u[n],o=t[n];o&&(e[r]=o,delete t[n])}return e}function a(t,e){if(!t)return"div";var n=t.split(/([\.#]?[a-zA-Z0-9_:-]+)/),r="div";return n.filter(Boolean).forEach(function(t){var n=t.charAt(0);"."===n?e["class"]=((e["class"]||"")+" "+t.substring(1,t.length)).trim():"#"===n?e.id=t.substring(1,t.length):r=t}),r}var c=t("component/type"),u={onBlur:"blur",onChange:"change",onClick:"click",onContextMenu:"contextmenu",onCopy:"copy",onCut:"cut",onDoubleClick:"dblclick",onDrag:"drag",onDragEnd:"dragend",onDragEnter:"dragenter",onDragExit:"dragexit",onDragLeave:"dragleave",onDragOver:"dragover",onDragStart:"dragstart",onDrop:"drop",onFocus:"focus",onInput:"input",onKeyDown:"keydown",onKeyUp:"keyup",onMouseDown:"mousedown",onMouseMove:"mousemove",onMouseOut:"mouseout",onMouseOver:"mouseover",onMouseUp:"mouseup",onPaste:"paste",onScroll:"scroll",onSubmit:"submit",onTouchCancel:"touchcancel",onTouchEnd:"touchend",onTouchMove:"touchmove",onTouchStart:"touchstart"};e.exports=function(t,e,r,o){var i={};return i.type="element",i.attributes=n(e),i.events=s(e),i.tagName=a(t,e),i.children=o||[],i.key=r,i}},{"component/type":10}],17:[function(t,e){e.exports=function(t){var e={};return e.type="text",e.data=String(t),e}},{}],18:[function(t,e){function n(t){this.root=t,this.paths={},this.nodes={},this.components={},this.parse(t)}e.exports=function(t){return new n(t)},n.prototype.getPath=function(t){return this.paths[t.id]},n.prototype.getNode=function(t){return this.nodes[t]},n.prototype.parse=function(t,e){e=e||"0",this.paths[t.id]=e,this.nodes[e]=t,"component"===t.type&&(this.components[e]=t),t.children&&t.children.forEach(function(t,n){this.parse(t,e+"."+(t.key||n))},this)}},{}],12:[function(t,e){function n(t,e){this.id=(++u).toString(32),this.type=t,this.props=e||{},this.component=this.createComponent(t),this.state=this.component.initialState(this.props),this.children={},this.current=null,this.previous=null,this.dirty=!1,this.lifecycle=null,this._pendingProps=null,this._pendingState=null,this._propsReplaced=!1}var r=t("ianstormtaylor/to-camel-case"),o=t("sindresorhus/object-assign"),i=t("component/emitter"),s=t("jkroso/equals"),a=t("component/each"),c=t("../virtual"),u=0;e.exports=n,i(n.prototype),n.prototype.createComponent=function(t){var e=new t;return e.on("change",this.setState.bind(this)),e},n.prototype.render=function(){this.lifecycle="rendering";var t=this.getProps(),e=this.component.render(t,this.state);return this.lifecycle=null,e||(e=c.node("noscript")),c.tree(e)},n.prototype.setProps=function(t,e){e&&this.once("update",e),this._pendingProps=o(this._pendingProps||{},t),this.propsChanged(t),this.invalidate()},n.prototype.replaceProps=function(t,e){e&&this.once("update",e),this._propsReplaced=!0,this._pendingProps=t,this.propsChanged(t),this.invalidate()},n.prototype.validateProps=function(){this.type.props},n.prototype.setState=function(t,e){if("beforeUpdate"===this.lifecycle)throw new Error("You can't call setState in the beforeUpdate hook. Use the propsChanged hook instead.");if("rendering"===this.lifecycle)throw new Error("You can't call setState in the render hook. This method must remain pure.");e&&this.once("update",e),this._pendingState=o(this._pendingState||{},t),this.invalidate()},n.prototype.invalidate=function(){this.dirty=!0,this.scene&&(this.scene.dirty=!0)},n.prototype.addChild=function(t,e,r){var o=new n(e,r);return this.children[t]=o,o.addToScene(this.scene),o},n.prototype.getChild=function(t){return this.children[t]},n.prototype.getPath=function(t){return this.current.getPath(t)},n.prototype.addToScene=function(t){this.scene=t},n.prototype.removeChild=function(t){var e=this.children[t];return e.scene=null,delete this.children[t],e},n.prototype.shouldUpdate=function(t,e){return e&&!s(e,this.props)?!0:t&&!s(t,this.state)?!0:!1},n.prototype.update=function(){var t;this._propsReplaced?(t=this._pendingProps,this._propsReplaced=!1):t=o({},this.props,this._pendingProps);var e=o({},this.state,this._pendingState);if(!this.shouldUpdate(e,t))return!1;this.beforeUpdate(e,t);this.state,this.props;return this.state=e,this.props=t||this.props,this._pendingState=null,this._pendingProps=null,delete this.state.__force__,!0},n.prototype.setCurrent=function(t){this.previous=this.current,this.current=t,this.dirty=!1},n.prototype.remove=function(){this.off(),a(this.children,function(t,e){e.remove()}),this.children={}},n.prototype.connect=function(){var t=this.channels={},e=this.scene;this.type.channels.forEach(function(n){var o=e.channel(n).connect();t[r(n)]=o})},n.prototype.disconnect=function(){for(var t in this.channels){var e=this.channels[t];e.disconnect()}delete this.channels},n.prototype.getProps=function(){var t=Object.create(this.props);return t.channels=this.channels,t},n.prototype.beforeUpdate=function(t,e){var n=this.getProps();this.lifecycle="beforeUpdate",this.component.beforeUpdate(n,this.state,e,t),this.type.emit("beforeUpdate",this.component,n,this.state,e,t),this.lifecycle=null},n.prototype.afterUpdate=function(t,e){var n=this.getProps();this.emit("update"),this.component.afterUpdate(n,this.state,e,t),this.type.emit("afterUpdate",this.component,n,this.state,e,t)},n.prototype.beforeUnmount=function(t){var e=this.getProps();this.component.beforeUnmount(t,e,this.state),this.type.emit("beforeUnmount",this.component,t,e,this.state)},n.prototype.afterUnmount=function(){this.disconnect();var t=this.getProps();this.component.afterUnmount(t,this.state),this.type.emit("afterUnmount",this.component,t,this.state)},n.prototype.beforeMount=function(){this.connect();var t=this.getProps();this.component.beforeMount(t,this.state),this.type.emit("beforeMount",this.component,t,this.state)},n.prototype.afterMount=function(t){var e=this.getProps();this.component.afterMount(t,e,this.state),this.type.emit("afterMount",this.component,t,e,this.state)},n.prototype.propsChanged=function(t){var e=this.getProps();this.component.propsChanged(t,e,this.state),this.type.emit("propsChanged",this.component,t,e,this.state)}},{"ianstormtaylor/to-camel-case":19,"sindresorhus/object-assign":4,"component/emitter":6,"jkroso/equals":20,"component/each":21,"../virtual":3}],19:[function(t,e){function n(t){return r(t).replace(/\s(\w)/g,function(t,e){return e.toUpperCase()})}var r=t("to-space-case");e.exports=n},{"to-space-case":22}],22:[function(t,e){function n(t){return r(t).replace(/[\W_]+(.|$)/g,function(t,e){return e?" "+e:""})}var r=t("to-no-case");e.exports=n},{"to-no-case":23}],23:[function(t,e){function n(t){return i.test(t)?t.toLowerCase():(a.test(t)&&(t=r(t)),s.test(t)&&(t=o(t)),t.toLowerCase())}function r(t){return t.replace(c,function(t,e){return e?" "+e:""})}function o(t){return t.replace(u,function(t,e,n){return e+" "+n.toLowerCase().split("").join(" ")})}e.exports=n;var i=/\s/,s=/[a-z][A-Z]/,a=/[\W_]/,c=/[\W_]+(.|$)/g,u=/(.)([A-Z]+)/g},{}],20:[function(t,e){function n(t,e,n){if(t===e)return!0;var r=c[a(t)],o=c[a(e)];return r&&r===o?r(t,e,n):!1}function r(t){return function(e,n,r){if(!r)return t(e,n,[]);for(var o,i=r.length;o=r[--i];)if(o[0]===e&&o[1]===n)return!0;return t(e,n,r)}}function o(t,e,r){var o=t.length;if(o!==e.length)return!1;for(r.push([t,e]);o--;)if(!n(t[o],e[o],r))return!1;return!0}function i(t,e,r){if("function"==typeof t.equal)return r.push([t,e]),t.equal(e,r);var o=s(t),i=s(e),a=o.length;if(a!==i.length)return!1;for(o.sort(),i.sort();a--;)if(o[a]!==i[a])return!1;for(r.push([t,e]),a=o.length;a--;){var c=o[a];if(!n(t[c],e[c],r))return!1}return!0}function s(t){var e=[];for(var n in t)"constructor"!==n&&e.push(n);return e}var a=t("type"),c={};c.number=function(t,e){return t!==t&&e!==e},c["function"]=function(t,e,r){return t.toString()===e.toString()&&c.object(t,e,r)&&n(t.prototype,e.prototype)},c.date=function(t,e){return+t===+e},c.regexp=function(t,e){return t.toString()===e.toString()},c.element=function(t,e){return t.outerHTML===e.outerHTML},c.textnode=function(t,e){return t.textContent===e.textContent},c.arguments=c.array=r(o),c.object=r(i),e.exports=n},{type:24}],24:[function(t,e,n){var r={}.toString,o="undefined"!=typeof window?window.Node:Function;e.exports=n=function(t){var e=typeof t;if("object"!=e)return e;if(e=i[r.call(t)])return e;if(t instanceof o)switch(t.nodeType){case 1:return"element";case 3:return"text-node";case 9:return"document";case 11:return"document-fragment";default:return"dom-node"}};var i=n.types={"[object Function]":"function","[object Date]":"date","[object RegExp]":"regexp","[object Arguments]":"arguments","[object Array]":"array","[object String]":"string","[object Null]":"null","[object Undefined]":"undefined","[object Number]":"number","[object Boolean]":"boolean","[object Object]":"object","[object Text]":"text-node","[object Uint8Array]":"bit-array","[object Uint16Array]":"bit-array","[object Uint32Array]":"bit-array","[object Uint8ClampedArray]":"bit-array","[object Error]":"error","[object FormData]":"form-data","[object File]":"file","[object Blob]":"blob"}},{}],21:[function(t,e){function n(t,e,n){for(var r=0;r<t.length;++r)e.call(n,t.charAt(r),r)}function r(t,e,n){for(var r in t)c.call(t,r)&&e.call(n,r,t[r])}function o(t,e,n){for(var r=0;r<t.length;++r)e.call(n,t[r],r)}try{var i=t("type")}catch(s){var i=t("component-type")}var a=t("to-function"),c=Object.prototype.hasOwnProperty;e.exports=function(t,e,s){switch(e=a(e),s=s||this,i(t)){case"array":return o(t,e,s);case"object":return"number"==typeof t.length?o(t,e,s):r(t,e,s);case"string":return n(t,e,s)}}},{type:25,"component-type":25,"to-function":26}],25:[function(t,e){var n=Object.prototype.toString;e.exports=function(t){switch(n.call(t)){case"[object Function]":return"function";case"[object Date]":return"date";case"[object RegExp]":return"regexp";case"[object Arguments]":return"arguments";case"[object Array]":return"array";case"[object String]":return"string"}return null===t?"null":void 0===t?"undefined":t&&1===t.nodeType?"element":t===Object(t)?"object":typeof t}},{}],26:[function(t,e){function n(t){switch({}.toString.call(t)){case"[object Object]":return s(t);case"[object Function]":return t;case"[object String]":return i(t);case"[object RegExp]":return o(t);default:return r(t)}}function r(t){return function(e){return t===e}}function o(t){return function(e){return t.test(e)}}function i(t){return/^ *\W+/.test(t)?new Function("_","return _ "+t):new Function("_","return "+a(t))}function s(t){var e={};for(var o in t)e[o]="string"==typeof t[o]?r(t[o]):n(t[o]);return function(t){if("object"!=typeof t)return!1;for(var n in e){if(!(n in t))return!1;if(!e[n](t[n]))return!1}return!0}}function a(t){var e=u(t);if(!e.length)return"_."+t;var n,r,o;for(r=0;r<e.length;r++)o=e[r],n="_."+o,n="('function' == typeof "+n+" ? "+n+"() : "+n+")",t=c(o,t,n);return t}function c(t,e,n){return e.replace(new RegExp("(\\.)?"+t,"g"),function(t,e){return e?t:n})}var u;try{u=t("props")}catch(p){u=t("component-props")}e.exports=n},{props:27,"component-props":27}],27:[function(t,e){function n(t){return t.replace(/\.\w+|\w+ *\(|"[^"]*"|'[^']*'|\/([^/]+)\//g,"").replace(s,"").match(/[$a-zA-Z_]\w*/g)||[]}function r(t,e,n){var r=/\.\w+|\w+ *\(|"[^"]*"|'[^']*'|\/([^/]+)\/|[a-zA-Z_]\w*/g;return t.replace(r,function(t){return"("==t[t.length-1]?n(t):~e.indexOf(t)?n(t):t})}function o(t){for(var e=[],n=0;n<t.length;n++)~e.indexOf(t[n])||e.push(t[n]);return e}function i(t){return function(e){return t+e}}var s=/\b(this|Array|Date|Object|Math|JSON)\b/g;e.exports=function(t,e){var s=o(n(t));return e&&"string"==typeof e&&(e=i(e)),e?r(t,s,e):s}},{}],13:[function(t,e){function n(t,e){this.tick=this.update.bind(this),this.signals=new o,this.renderer=t,this.dirty=!0,this.entity=e,e.addToScene(this),this.resume()}var r=t("component/emitter"),o=t("segmentio/tower"),i=t("./loop");e.exports=n,r(n.prototype),n.prototype.use=function(t){return t(this),this},n.prototype.channel=function(t){return this.signals.channel(t)},n.prototype.update=function(){return this.dirty?(this.dirty=!1,this.renderer.render(this.entity),this.emit("update"),this):void 0},n.prototype.setProps=function(t,e){e&&this.once("update",e),this.entity.setProps(t);var n=this;return"undefined"!=typeof Promise?new Promise(function(t){n.once("update",function(){t()})}):void 0},n.prototype.replaceProps=function(t,e){e&&this.once("update",e),this.entity.replaceProps(t);var n=this;return"undefined"!=typeof Promise?new Promise(function(t){n.once("update",function(){t()})}):void 0},n.prototype.remove=function(){this.pause(),this.signals.closeAll(),this.renderer.clear(),this.off()},n.prototype.resume=function(){return i.on("tick",this.tick),this.emit("resume"),this},n.prototype.pause=function(){return i.off("tick",this.tick),this.emit("pause"),this}},{"component/emitter":6,"segmentio/tower":28,"./loop":29}],28:[function(t,e){function n(){this.channels={}}function r(){this.sockets=[]}function o(t,e){var n=e.indexOf(t);-1!==n&&e.splice(n,1)}var i=t("component/emitter");e.exports=n,n.prototype.closeAll=function(){for(var t in this.channels){var e=this.channels[t];e.close()}},n.prototype.channel=function(t){var e=this.channels;if(e[t])return e[t];var n=new r;return n.on("close",function(){delete e[t]}),e[t]=n,n},i(r.prototype),r.prototype.connect=function(t){var e=this,n=new i;return n.disconnect=function(){o(n,e.sockets),e.emit("disconnect",n,t),n.emit("disconnect",t),n.off()},this.sockets.push(n),this.emit("connection",n,t),n},r.prototype.broadcast=function(t,e){this.sockets.forEach(function(n){n.emit(t,e)})},r.prototype.close=function(){for(;this.sockets.length;){var t=this.sockets.pop();t.disconnect()}this.emit("close"),this.off()}},{"component/emitter":6}],29:[function(t,e){function n(t){i.emit("tick",t),r(n)}var r=t("component/raf"),o=t("component/emitter"),i=new o;r(n),e.exports=i},{"component/raf":30,"component/emitter":6}],30:[function(t,e,n){function r(t){var e=(new Date).getTime(),n=Math.max(0,16-(e-o)),r=setTimeout(t,n);return o=e,r}n=e.exports=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||r;var o=(new Date).getTime(),i=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.clearTimeout;n.cancel=function(t){i.call(window,t)}},{}],14:[function(t,e){function n(t){this.container=t,this.events=new r(t),this.elements={},this.rendered=null}var r=t("./interactions"),o=t("component/each"),i=t("./diff");e.exports=n,n.prototype.render=function(t){return t.current?void this.update(t):(this.clear(),this.mountEntity(t,this.container),void(this.rendered=t))},n.prototype.update=function(t){if(!t.dirty)return this.updateChildren(t);var e=t.state,n=t.props,r=t.update();if(!r)return this.updateChildren(t);var o=t.render(),s=i(t,o,this.getElement(t.id),this);this.elements[t.id]=s,t.setCurrent(o),this.updateEvents(t),this.updateChildren(t),t.afterUpdate(e,n)},n.prototype.updateChildren=function(t){for(var e in t.children)this.update(t.children[e])},n.prototype.clear=function(){this.rendered&&(this.unmountEntity(this.rendered),this.rendered=null)},n.prototype.mountEntity=function(t,e){t.beforeMount();var n=this.addEntity(t,e);return e.appendChild(n),this.updateEvents(t),t.afterMount(n),n},n.prototype.unmountEntity=function(t){var e=this.getElement(t.id);e&&(t.beforeUnmount(e),e.parentNode&&e.parentNode.removeChild(e),this.unmountChildren(t),this.removeEvents(t),t.afterUnmount(),t.remove(),delete this.elements[t.id])},n.prototype.unmountChildren=function(t){var e=this;o(t.children,function(n,r){t.removeChild(n),e.unmountEntity(r)})},n.prototype.getElement=function(t){return this.elements[t]},n.prototype.updateEvents=function(t){var e=this;this.events.unbind(t.id),o(t.current.nodes,function(n,r){"element"===r.type&&o(r.events,function(r,o){e.events.bind(t.id,n,r,function(e){o.call(t.component,e,t.props,t.state)})})})},n.prototype.removeEvents=function(t){this.events.unbind(t.id)},n.prototype.addEntity=function(t,e){var n=t.render(),r=this.createElement(n.root,n,t,e);return t.setCurrent(n),this.elements[t.id]=r,r},n.prototype.createElement=function(t,e,n,r){var o=e.getPath(t),i=r||document.createDocumentFragment();if(!o)throw new Error("Node does not exist in the entity");if("text"===t.type)return i.appendChild(document.createTextNode(t.data)),i;if("element"===t.type){var s=document.createElement(t.tagName),a=t.children;for(var c in t.attributes)s.setAttribute(c,t.attributes[c]);s.__path__=o,s.__entity__=n.id;for(var u=0,p=a.length;p>u;u++)this.createElement(a[u],e,n,s);return i.appendChild(s),s}if("component"===t.type){var h=n.addChild(o,t.component,t.props);return this.mountEntity(h,i)}}},{"./interactions":31,"component/each":21,"./diff":32}],31:[function(t,e){function n(t){this.el=t,this.handlers={},this.handle=r.bind(this),this.resume()}function r(t){var e=t.target,n=(this.handlers,i.get(this.handlers,[e.__entity__,e.__path__,t.type]));n&&n(t)}var o=(t("component/delegate"),t("component/per-frame")),i=t("./keypath"),s=["blur","change","click","contextmenu","copy","cut","dblclick","drag","dragend","dragenter","dragexit","dragleave","dragover","dragstart","drop","focus","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","paste","scroll","submit","touchcancel","touchend","touchmove","touchstart","wheel"];e.exports=n,n.prototype.bind=function(t,e,n,r){i.set(this.handlers,[t,e,n],o(r))},n.prototype.unbind=function(t){delete this.handlers[t]},n.prototype.resume=function(){s.forEach(function(t){this.el.addEventListener(t,this.handle,!0)},this)},n.prototype.pause=function(){s.forEach(function(t){this.el.removeEventListener(t,this.handle)},this)},n.prototype.remove=function(){this.handlers={},this.pause()}},{"component/delegate":33,"component/per-frame":34,"./keypath":35}],33:[function(t,e,n){var r=t("closest"),o=t("event");n.bind=function(t,e,n,i,s){return o.bind(t,n,function(n){var o=n.target||n.srcElement;n.delegateTarget=r(o,e,!0,t),n.delegateTarget&&i.call(t,n)},s)},n.unbind=function(t,e,n,r){o.unbind(t,e,n,r)}},{closest:36,event:37}],36:[function(t,e){var n=t("matches-selector");e.exports=function(t,e,r,o){for(t=r?{parentNode:t}:t,o=o||document;(t=t.parentNode)&&t!==document;){if(n(t,e))return t;if(t===o)return}}},{"matches-selector":38}],38:[function(t,e){function n(t,e){if(!t||1!==t.nodeType)return!1;if(i)return i.call(t,e);for(var n=r.all(e,t.parentNode),o=0;o<n.length;++o)if(n[o]==t)return!0;return!1}var r=t("query"),o=Element.prototype,i=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.msMatchesSelector||o.oMatchesSelector;e.exports=n},{query:39}],39:[function(t,e,n){function r(t,e){return e.querySelector(t)}n=e.exports=function(t,e){return e=e||document,r(t,e)},n.all=function(t,e){return e=e||document,e.querySelectorAll(t)},n.engine=function(t){if(!t.one)throw new Error(".one callback required");if(!t.all)throw new Error(".all callback required");return r=t.one,n.all=t.all,n}},{}],37:[function(t,e,n){var r=window.addEventListener?"addEventListener":"attachEvent",o=window.removeEventListener?"removeEventListener":"detachEvent",i="addEventListener"!==r?"on":"";n.bind=function(t,e,n,o){return t[r](i+e,n,o||!1),n},n.unbind=function(t,e,n,r){return t[o](i+e,n,r||!1),n}},{}],34:[function(t,e){function n(t){var e,n=!1;return function(){return n?e:(n=!0,r(function(){n=!1}),e=t.apply(this,arguments))}}var r=t("raf");e.exports=n},{raf:40}],40:[function(t,e,n){function r(t){var e=(new Date).getTime(),n=Math.max(0,16-(e-o)),r=setTimeout(t,n);return o=e,r}n=e.exports=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||r;var o=(new Date).getTime(),i=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||window.clearTimeout;n.cancel=function(t){i.call(window,t)}},{}],35:[function(t,e,n){n.get=function(t,e){for(var n=e,r=t;n.length;){var o=n.shift();r=r[o],void 0===r&&(n.length=0)}return r},n.set=function(t,e,n){for(var r=e,o=t,i=r.pop();r.length;){var s=r.shift();o[s]||(o[s]={}),o=o[s]}o[i]=n}},{}],32:[function(t,e){function n(t,e,n,o){var i={entity:t,nextTree:e,renderer:o,rootEl:n,el:n,path:"0",id:t.id,isRoot:!0};return r(t.current.root,e.root,i),i.rootEl}function r(t,e,n){return t.type!==e.type?u(t,e,n):"text"===e.type?o(t,e,n):"component"===e.type?a(t,e,n):"element"===e.type?c(t,e,n):void 0}function o(t,e,n){e.data!==t.data&&(n.el.data=e.data)}function i(t,e,n){for(var o=h(t.children,e.children),i=n.el,s=-1,a=0;a<o.length;a++){s+=1;var c=o[a],u=c[0],f=c[1];null!=u?null!=f?r(u,f,{el:i.childNodes[s],entity:n.entity,nextTree:n.nextTree,renderer:n.renderer,isRoot:!1,path:n.path+"."+s}):(p(u,n),"component"!=u.type&&i.removeChild(i.childNodes[s]),s-=1):n.renderer.createElement(f,n.nextTree,n.entity,i)}}function s(t,e,n){var r=e.attributes,o=t.attributes;for(var i in r){var s=r[i];o[i]&&o[i]===s||n.el.setAttribute(i,s)}for(var a in o)r[a]||n.el.removeAttribute(a)}function a(t,e,n){if(e.component!==t.component)return u(t,e,n);var r=n.entity.getChild(n.path);r.replaceProps(e.props)}function c(t,e,n){return e.tagName!==t.tagName?u(t,e,n):(s(t,e,n),void i(t,e,n))}function u(t,e,n){var r=n.el,o=r.parentNode;p(t,n),r.parentNode&&r.parentNode.removeChild(r);var i=n.renderer.createElement(e,n.nextTree,n.entity);o.insertBefore(i,o.childNodes[t.index]),n.isRoot&&(n.rootEl=i)}function p(t,e){if("component"===t.type){var n=e.entity.current.getPath(t),r=e.entity.removeChild(n);return void e.renderer.unmountEntity(r)}t.children&&t.children.forEach(function(t){p(t,e)},this)}function h(){var t=Array.prototype.slice.call(arguments,0);return t.reduce(function(t,e){return t.length>e.length?t:e},[]).map(function(e,n){return t.map(function(t){return t[n]})})}t("jkroso/equals");e.exports=n},{"jkroso/equals":20}],8:[function(t,e,n){t("sindresorhus/object-assign");n.setState=function(t,e){this.emit("change",t,e)},n.invalidate=function(){this.emit("change",{__force__:!0})},n.render=function(){return null},n.initialState=function(){return{}},n.beforeMount=function(){},n.afterMount=function(){},n.beforeUpdate=function(){},n.afterUpdate=function(){},n.beforeUnmount=function(){},n.afterUnmount=function(){},n.propsChanged=function(){}},{"sindresorhus/object-assign":4}]},{},{1:""}));
!function(t){"object"==typeof exports?module.exports=t("1"):"function"==typeof define&&define.amd?define(function(){return t("1")}):this.deku=t("1")}(function t(e,n,r){function o(t){if(n[t])return n[t].exports;if(e[t])return i(t,o);throw new Error('cannot find module "'+t+'"')}function i(o,i){var s=n[o]={exports:{}},a=e[o],c=a[2],u=a[0];return u.call(s.exports,function(t){var n=e[o][1][t];return i(n?n:t)},s,s.exports,t,e,n,r),c&&(n[c]=n[o]),n[o].exports}var s=function(){return this}();for(var a in r)r[a]?s[r[a]]=o(a):o(a);return o.duo=!0,o.cache=n,o.modules=e,o}({1:[function(t,e,n){n.component=t("./lib/component"),n.dom=t("./lib/virtual").node},{"./lib/component":2,"./lib/virtual":3}],2:[function(t,e){function n(t){function e(){return this instanceof e?void o(this):c(e,arguments[0],arguments[1])}if(t=t||{},"function"==typeof t&&(t={render:t}),e.props={},e.channels=[],r(e,s,i.prototype),r(e.prototype,a,t,i.prototype),t.displayName&&(e.displayName=t.displayName,delete t.displayName),t.props){for(var n in t.props)e.prop(n,t.props[n]);delete t.props}return t.channels&&(t.channels.forEach(function(t){e.channel(t)}),delete t.channels),e}var r=t("sindresorhus/object-assign"),o=t("segmentio/bind-all"),i=t("component/emitter"),s=t("./statics"),a=t("./protos"),c=t("../virtual").node;e.exports=n},{"sindresorhus/object-assign":4,"segmentio/bind-all":5,"component/emitter":6,"./statics":7,"./protos":8,"../virtual":3}],4:[function(t,e){"use strict";function n(t){if(null==t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}e.exports=Object.assign||function(t){for(var e,r,o,i=n(t),s=1;s<arguments.length;s++){r=arguments[s],o=Object.keys(Object(r));for(var a=0;a<o.length;a++)try{i[o[a]]=r[o[a]]}catch(c){void 0===e&&(e=c)}}if(e)throw e;return i}},{}],5:[function(t,e){try{var n=t("bind"),r=t("type")}catch(o){var n=t("bind-component"),r=t("type-component")}e.exports=function(t){for(var e in t){var o=t[e];"function"===r(o)&&(t[e]=n(t,t[e]))}return t}},{bind:9,type:10}],9:[function(t,e){var n=[].slice;e.exports=function(t,e){if("string"==typeof e&&(e=t[e]),"function"!=typeof e)throw new Error("bind() requires a function");var r=n.call(arguments,2);return function(){return e.apply(t,r.concat(n.call(arguments)))}}},{}],10:[function(t,e){var n=Object.prototype.toString;e.exports=function(t){switch(n.call(t)){case"[object Date]":return"date";case"[object RegExp]":return"regexp";case"[object Arguments]":return"arguments";case"[object Array]":return"array";case"[object Error]":return"error"}return null===t?"null":void 0===t?"undefined":t!==t?"nan":t&&1===t.nodeType?"element":(t=t.valueOf?t.valueOf():Object.prototype.valueOf.apply(t),typeof t)}},{}],6:[function(t,e){function n(t){return t?r(t):void 0}function r(t){for(var e in n.prototype)t[e]=n.prototype[e];return t}e.exports=n,n.prototype.on=n.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks[t]=this._callbacks[t]||[]).push(e),this},n.prototype.once=function(t,e){function n(){r.off(t,n),e.apply(this,arguments)}var r=this;return this._callbacks=this._callbacks||{},n.fn=e,this.on(t,n),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n=this._callbacks[t];if(!n)return this;if(1==arguments.length)return delete this._callbacks[t],this;for(var r,o=0;o<n.length;o++)if(r=n[o],r===e||r.fn===e){n.splice(o,1);break}return this},n.prototype.emit=function(t){this._callbacks=this._callbacks||{};var e=[].slice.call(arguments,1),n=this._callbacks[t];if(n){n=n.slice(0);for(var r=0,o=n.length;o>r;++r)n[r].apply(this,e)}return this},n.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks[t]||[]},n.prototype.hasListeners=function(t){return!!this.listeners(t).length}},{}],7:[function(t,e,n){var r=t("../renderer/string"),o=t("../entity"),i=t("../scene");if("undefined"!=typeof window)var s=t("../renderer/html");n.use=function(t){if("function"==typeof t)t(this);else for(var e in t)this.prototype[e]=t[e];return this},n.prop=function(t,e){return this.props[t]=e,this},n.channel=function(t){return this.channels.push(t),this},n.render=function(t,e){if(!s)throw new Error("You can only render a DOM tree in the browser. Use renderString instead.");var n=new s(t),r=new o(this,e),a=new i(n,r);return a},n.renderString=function(t){var e=new o(this,t);return r(e)}},{"../renderer/string":11,"../entity":12,"../scene":13,"../renderer/html":14}],11:[function(t,e){function n(t){var e=t.render();return r(e.root,e)}function r(t,e){e.getPath(t);if("text"===t.type)return t.data;if("element"===t.type){for(var i=t.children,a=t.attributes,c=t.tagName,u="<"+c+o(a)+">",p=0,h=i.length;h>p;p++)u+=r(i[p],e);return u+="</"+c+">"}if("component"===t.type)return n(new s(t.component,t.props));throw new Error("Invalid type")}function o(t){var e="";for(var n in t)e+=i(n,t[n]);return e}function i(t,e){return" "+t+'="'+e+'"'}var s=(t("../../virtual"),t("../../entity"));e.exports=n},{"../../virtual":3,"../../entity":12}],3:[function(t,e,n){function r(t,e,n){2!==arguments.length||"string"!=typeof e&&!Array.isArray(e)||(n=e,e={}),n=n||[],e=e||{},Array.isArray(n)||(n=[n]),n=n.map(o);var r=e.key;delete e.key;var a;return a="function"==typeof t?i(t,e,r,n):s(t,e,r,n),a.id=(++u).toString(32),a}function o(t,e){if(("string"==typeof t||"number"==typeof t)&&(t=a(String(t))),Array.isArray(t))throw new Error("Child node cant be an array. This can happen if you try to use props.children like a node.");return t.index=e,t}var i=t("./component"),s=t("./element"),a=t("./text"),c=t("./tree");n.node=r,n.tree=c;var u=0},{"./component":15,"./element":16,"./text":17,"./tree":18}],15:[function(t,e){e.exports=function(t,e,n,r){var o={};return o.key=n,o.props=e,o.type="component",o.component=t,o.props.children=r||[],o}},{}],16:[function(t,e){function n(t){t.style&&(t.style=r(t.style)),t.data&&(t=o(t)),t["class"]&&(t["class"]=i(t["class"]));for(var e in t)t[e]===!1&&delete t[e];return t}function r(t){if("object"!==c(t))return t;var e="";for(var n in t){var r=t[n];e+=n+":"+r+";"}return e}function o(t){if("object"!==c(t.data))return t;for(var e in t.data)t["data-"+e]=t.data[e];return delete t.data,t}function i(t){if("object"===c(t)){var e=[];for(var n in t)t[n]&&e.push(n);t=e}if("array"===c(t)){if(0===t.length)return;t=t.join(" ")}return t}function s(t){var e={};for(var n in u){var r=u[n],o=t[n];o&&(e[r]=o,delete t[n])}return e}function a(t,e){if(!t)return"div";var n=t.split(/([\.#]?[a-zA-Z0-9_:-]+)/),r="div";return n.filter(Boolean).forEach(function(t){var n=t.charAt(0);"."===n?e["class"]=((e["class"]||"")+" "+t.substring(1,t.length)).trim():"#"===n?e.id=t.substring(1,t.length):r=t}),r}var c=t("component/type"),u={onBlur:"blur",onChange:"change",onClick:"click",onContextMenu:"contextmenu",onCopy:"copy",onCut:"cut",onDoubleClick:"dblclick",onDrag:"drag",onDragEnd:"dragend",onDragEnter:"dragenter",onDragExit:"dragexit",onDragLeave:"dragleave",onDragOver:"dragover",onDragStart:"dragstart",onDrop:"drop",onFocus:"focus",onInput:"input",onKeyDown:"keydown",onKeyUp:"keyup",onMouseDown:"mousedown",onMouseMove:"mousemove",onMouseOut:"mouseout",onMouseOver:"mouseover",onMouseUp:"mouseup",onPaste:"paste",onScroll:"scroll",onSubmit:"submit",onTouchCancel:"touchcancel",onTouchEnd:"touchend",onTouchMove:"touchmove",onTouchStart:"touchstart"};e.exports=function(t,e,r,o){var i={};return i.type="element",i.attributes=n(e),i.events=s(e),i.tagName=a(t,e),i.children=o||[],i.key=r,i}},{"component/type":10}],17:[function(t,e){e.exports=function(t){var e={};return e.type="text",e.data=String(t),e}},{}],18:[function(t,e){function n(t){this.root=t,this.paths={},this.nodes={},this.components={},this.parse(t)}e.exports=function(t){return new n(t)},n.prototype.getPath=function(t){return this.paths[t.id]},n.prototype.getNode=function(t){return this.nodes[t]},n.prototype.parse=function(t,e){e=e||"0",this.paths[t.id]=e,this.nodes[e]=t,"component"===t.type&&(this.components[e]=t),t.children&&t.children.forEach(function(t,n){this.parse(t,e+"."+(t.key||n))},this)}},{}],12:[function(t,e){function n(t,e){this.id=(++u).toString(32),this.type=t,this.props=e||{},this.component=this.createComponent(t),this.state=this.component.initialState(this.props),this.children={},this.current=null,this.previous=null,this.dirty=!1,this.lifecycle=null,this._pendingProps=null,this._pendingState=null,this._propsReplaced=!1}var r=t("ianstormtaylor/to-camel-case"),o=t("sindresorhus/object-assign"),i=t("component/emitter"),s=t("jkroso/equals"),a=t("component/each"),c=t("../virtual"),u=0;e.exports=n,i(n.prototype),n.prototype.createComponent=function(t){var e=new t;return e.on("change",this.setState.bind(this)),e},n.prototype.render=function(){this.lifecycle="rendering";var t=this.getProps(),e=this.component.render(t,this.state);return this.lifecycle=null,e||(e=c.node("noscript")),c.tree(e)},n.prototype.setProps=function(t,e){e&&this.once("update",e),this._pendingProps=o(this._pendingProps||{},t),this.propsChanged(t),this.invalidate()},n.prototype.replaceProps=function(t,e){e&&this.once("update",e),this._propsReplaced=!0,this._pendingProps=t,this.propsChanged(t),this.invalidate()},n.prototype.validateProps=function(){this.type.props},n.prototype.setState=function(t,e){if("beforeUpdate"===this.lifecycle)throw new Error("You can't call setState in the beforeUpdate hook. Use the propsChanged hook instead.");if("rendering"===this.lifecycle)throw new Error("You can't call setState in the render hook. This method must remain pure.");e&&this.once("update",e),this._pendingState=o(this._pendingState||{},t),this.invalidate()},n.prototype.invalidate=function(){this.dirty=!0,this.scene&&(this.scene.dirty=!0)},n.prototype.addChild=function(t,e,r){var o=new n(e,r);return this.children[t]=o,o.addToScene(this.scene),o},n.prototype.getChild=function(t){return this.children[t]},n.prototype.getPath=function(t){return this.current.getPath(t)},n.prototype.addToScene=function(t){this.scene=t},n.prototype.removeChild=function(t){var e=this.children[t];return e.scene=null,delete this.children[t],e},n.prototype.shouldUpdate=function(t,e){return e&&!s(e,this.props)?!0:t&&!s(t,this.state)?!0:!1},n.prototype.update=function(){var t;this._propsReplaced?(t=this._pendingProps,this._propsReplaced=!1):t=o({},this.props,this._pendingProps);var e=o({},this.state,this._pendingState);if(!this.shouldUpdate(e,t))return!1;this.beforeUpdate(e,t);this.state,this.props;return this.state=e,this.props=t||this.props,this._pendingState=null,this._pendingProps=null,delete this.state.__force__,!0},n.prototype.setCurrent=function(t){this.previous=this.current,this.current=t,this.dirty=!1},n.prototype.remove=function(){this.off(),a(this.children,function(t,e){e.remove()}),this.children={}},n.prototype.connect=function(){var t=this.channels={},e=this.scene;this.type.channels.forEach(function(n){var o=e.channel(n).connect();t[r(n)]=o})},n.prototype.disconnect=function(){for(var t in this.channels){var e=this.channels[t];e.disconnect()}delete this.channels},n.prototype.getProps=function(){var t=Object.create(this.props);return t.channels=this.channels,t},n.prototype.beforeUpdate=function(t,e){var n=this.getProps();this.lifecycle="beforeUpdate",this.component.beforeUpdate(n,this.state,e,t),this.type.emit("beforeUpdate",this.component,n,this.state,e,t),this.lifecycle=null},n.prototype.afterUpdate=function(t,e){var n=this.getProps();this.emit("update"),this.component.afterUpdate(n,this.state,e,t),this.type.emit("afterUpdate",this.component,n,this.state,e,t)},n.prototype.beforeUnmount=function(t){var e=this.getProps();this.component.beforeUnmount(t,e,this.state),this.type.emit("beforeUnmount",this.component,t,e,this.state)},n.prototype.afterUnmount=function(){this.disconnect();var t=this.getProps();this.component.afterUnmount(t,this.state),this.type.emit("afterUnmount",this.component,t,this.state)},n.prototype.beforeMount=function(){this.connect();var t=this.getProps();this.component.beforeMount(t,this.state),this.type.emit("beforeMount",this.component,t,this.state)},n.prototype.afterMount=function(t){var e=this.getProps();this.component.afterMount(t,e,this.state),this.type.emit("afterMount",this.component,t,e,this.state)},n.prototype.propsChanged=function(t){var e=this.getProps();this.component.propsChanged(t,e,this.state),this.type.emit("propsChanged",this.component,t,e,this.state)}},{"ianstormtaylor/to-camel-case":19,"sindresorhus/object-assign":4,"component/emitter":6,"jkroso/equals":20,"component/each":21,"../virtual":3}],19:[function(t,e){function n(t){return r(t).replace(/\s(\w)/g,function(t,e){return e.toUpperCase()})}var r=t("to-space-case");e.exports=n},{"to-space-case":22}],22:[function(t,e){function n(t){return r(t).replace(/[\W_]+(.|$)/g,function(t,e){return e?" "+e:""})}var r=t("to-no-case");e.exports=n},{"to-no-case":23}],23:[function(t,e){function n(t){return i.test(t)?t.toLowerCase():(a.test(t)&&(t=r(t)),s.test(t)&&(t=o(t)),t.toLowerCase())}function r(t){return t.replace(c,function(t,e){return e?" "+e:""})}function o(t){return t.replace(u,function(t,e,n){return e+" "+n.toLowerCase().split("").join(" ")})}e.exports=n;var i=/\s/,s=/[a-z][A-Z]/,a=/[\W_]/,c=/[\W_]+(.|$)/g,u=/(.)([A-Z]+)/g},{}],20:[function(t,e){function n(t,e,n){if(t===e)return!0;var r=c[a(t)],o=c[a(e)];return r&&r===o?r(t,e,n):!1}function r(t){return function(e,n,r){if(!r)return t(e,n,[]);for(var o,i=r.length;o=r[--i];)if(o[0]===e&&o[1]===n)return!0;return t(e,n,r)}}function o(t,e,r){var o=t.length;if(o!==e.length)return!1;for(r.push([t,e]);o--;)if(!n(t[o],e[o],r))return!1;return!0}function i(t,e,r){if("function"==typeof t.equal)return r.push([t,e]),t.equal(e,r);var o=s(t),i=s(e),a=o.length;if(a!==i.length)return!1;for(o.sort(),i.sort();a--;)if(o[a]!==i[a])return!1;for(r.push([t,e]),a=o.length;a--;){var c=o[a];if(!n(t[c],e[c],r))return!1}return!0}function s(t){var e=[];for(var n in t)"constructor"!==n&&e.push(n);return e}var a=t("type"),c={};c.number=function(t,e){return t!==t&&e!==e},c["function"]=function(t,e,r){return t.toString()===e.toString()&&c.object(t,e,r)&&n(t.prototype,e.prototype)},c.date=function(t,e){return+t===+e},c.regexp=function(t,e){return t.toString()===e.toString()},c.element=function(t,e){return t.outerHTML===e.outerHTML},c.textnode=function(t,e){return t.textContent===e.textContent},c.arguments=c.array=r(o),c.object=r(i),e.exports=n},{type:24}],24:[function(t,e,n){var r={}.toString,o="undefined"!=typeof window?window.Node:Function;e.exports=n=function(t){var e=typeof t;if("object"!=e)return e;if(e=i[r.call(t)])return e;if(t instanceof o)switch(t.nodeType){case 1:return"element";case 3:return"text-node";case 9:return"document";case 11:return"document-fragment";default:return"dom-node"}};var i=n.types={"[object Function]":"function","[object Date]":"date","[object RegExp]":"regexp","[object Arguments]":"arguments","[object Array]":"array","[object String]":"string","[object Null]":"null","[object Undefined]":"undefined","[object Number]":"number","[object Boolean]":"boolean","[object Object]":"object","[object Text]":"text-node","[object Uint8Array]":"bit-array","[object Uint16Array]":"bit-array","[object Uint32Array]":"bit-array","[object Uint8ClampedArray]":"bit-array","[object Error]":"error","[object FormData]":"form-data","[object File]":"file","[object Blob]":"blob"}},{}],21:[function(t,e){function n(t,e,n){for(var r=0;r<t.length;++r)e.call(n,t.charAt(r),r)}function r(t,e,n){for(var r in t)c.call(t,r)&&e.call(n,r,t[r])}function o(t,e,n){for(var r=0;r<t.length;++r)e.call(n,t[r],r)}try{var i=t("type")}catch(s){var i=t("component-type")}var a=t("to-function"),c=Object.prototype.hasOwnProperty;e.exports=function(t,e,s){switch(e=a(e),s=s||this,i(t)){case"array":return o(t,e,s);case"object":return"number"==typeof t.length?o(t,e,s):r(t,e,s);case"string":return n(t,e,s)}}},{type:25,"component-type":25,"to-function":26}],25:[function(t,e){var n=Object.prototype.toString;e.exports=function(t){switch(n.call(t)){case"[object Function]":return"function";case"[object Date]":return"date";case"[object RegExp]":return"regexp";case"[object Arguments]":return"arguments";case"[object Array]":return"array";case"[object String]":return"string"}return null===t?"null":void 0===t?"undefined":t&&1===t.nodeType?"element":t===Object(t)?"object":typeof t}},{}],26:[function(t,e){function n(t){switch({}.toString.call(t)){case"[object Object]":return s(t);case"[object Function]":return t;case"[object String]":return i(t);case"[object RegExp]":return o(t);default:return r(t)}}function r(t){return function(e){return t===e}}function o(t){return function(e){return t.test(e)}}function i(t){return/^ *\W+/.test(t)?new Function("_","return _ "+t):new Function("_","return "+a(t))}function s(t){var e={};for(var o in t)e[o]="string"==typeof t[o]?r(t[o]):n(t[o]);return function(t){if("object"!=typeof t)return!1;for(var n in e){if(!(n in t))return!1;if(!e[n](t[n]))return!1}return!0}}function a(t){var e=u(t);if(!e.length)return"_."+t;var n,r,o;for(r=0;r<e.length;r++)o=e[r],n="_."+o,n="('function' == typeof "+n+" ? "+n+"() : "+n+")",t=c(o,t,n);return t}function c(t,e,n){return e.replace(new RegExp("(\\.)?"+t,"g"),function(t,e){return e?t:n})}var u;try{u=t("props")}catch(p){u=t("component-props")}e.exports=n},{props:27,"component-props":27}],27:[function(t,e){function n(t){return t.replace(/\.\w+|\w+ *\(|"[^"]*"|'[^']*'|\/([^/]+)\//g,"").replace(s,"").match(/[$a-zA-Z_]\w*/g)||[]}function r(t,e,n){var r=/\.\w+|\w+ *\(|"[^"]*"|'[^']*'|\/([^/]+)\/|[a-zA-Z_]\w*/g;return t.replace(r,function(t){return"("==t[t.length-1]?n(t):~e.indexOf(t)?n(t):t})}function o(t){for(var e=[],n=0;n<t.length;n++)~e.indexOf(t[n])||e.push(t[n]);return e}function i(t){return function(e){return t+e}}var s=/\b(this|Array|Date|Object|Math|JSON)\b/g;e.exports=function(t,e){var s=o(n(t));return e&&"string"==typeof e&&(e=i(e)),e?r(t,s,e):s}},{}],13:[function(t,e){function n(t,e){this.tick=this.update.bind(this),this.signals=new o,this.renderer=t,this.dirty=!0,this.entity=e,e.addToScene(this),this.resume()}var r=t("component/emitter"),o=t("segmentio/tower@0.0.1"),i=t("./loop");e.exports=n,r(n.prototype),n.prototype.use=function(t){return t(this),this},n.prototype.channel=function(t){return this.signals.channel(t)},n.prototype.update=function(){return this.dirty?(this.dirty=!1,this.renderer.render(this.entity),this.emit("update"),this):void 0},n.prototype.setProps=function(t,e){e&&this.once("update",e),this.entity.setProps(t);var n=this;return"undefined"!=typeof Promise?new Promise(function(t){n.once("update",function(){t()})}):void 0},n.prototype.replaceProps=function(t,e){e&&this.once("update",e),this.entity.replaceProps(t);var n=this;return"undefined"!=typeof Promise?new Promise(function(t){n.once("update",function(){t()})}):void 0},n.prototype.remove=function(){this.pause(),this.signals.closeAll(),this.renderer.remove(),this.off()},n.prototype.resume=function(){return i.on("tick",this.tick),this.emit("resume"),this},n.prototype.pause=function(){return i.off("tick",this.tick),this.emit("pause"),this}},{"component/emitter":6,"segmentio/tower@0.0.1":28,"./loop":29}],28:[function(t,e){function n(){this.channels={}}function r(){this.sockets=[]}function o(t,e){var n=e.indexOf(t);-1!==n&&e.splice(n,1)}var i=t("component/emitter");e.exports=n,n.prototype.closeAll=function(){for(var t in this.channels){var e=this.channels[t];e.close()}},n.prototype.channel=function(t){var e=this.channels;if(e[t])return e[t];var n=new r;return n.on("close",function(){delete e[t]}),e[t]=n,n},i(r.prototype),r.prototype.connect=function(t){var e=this,n=new i;return n.disconnect=function(){o(n,e.sockets),e.emit("disconnect",n,t),n.emit("disconnect",t),n.off()},this.sockets.push(n),this.emit("connection",n,t),n},r.prototype.broadcast=function(t,e){this.sockets.forEach(function(n){n.emit(t,e)})},r.prototype.close=function(){for(;this.sockets.length;){var t=this.sockets.pop();t.disconnect()}this.emit("close"),this.off()}},{"component/emitter":6}],29:[function(t,e){function n(t){i.emit("tick",t),r(n)}var r=t("component/raf"),o=t("component/emitter"),i=new o;r(n),e.exports=i},{"component/raf":30,"component/emitter":6}],30:[function(t,e,n){function r(t){var e=(new Date).getTime(),n=Math.max(0,16-(e-o)),r=setTimeout(t,n);return o=e,r}n=e.exports=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||r;var o=(new Date).getTime(),i=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.clearTimeout;n.cancel=function(t){i.call(window,t)}},{}],14:[function(t,e){function n(t){this.container=t,this.events=new r(t),this.elements={},this.rendered=null}var r=t("./interactions"),o=t("component/each"),i=t("./diff");e.exports=n,n.prototype.render=function(t){return t.current?void this.update(t):(this.clear(),this.mountEntity(t,this.container),void(this.rendered=t))},n.prototype.update=function(t){if(!t.dirty)return this.updateChildren(t);var e=t.state,n=t.props,r=t.update();if(!r)return this.updateChildren(t);var o=t.render(),s=i(t,o,this.getElement(t.id),this);this.elements[t.id]=s,t.setCurrent(o),this.updateEvents(t),this.updateChildren(t),t.afterUpdate(e,n)},n.prototype.updateChildren=function(t){for(var e in t.children)this.update(t.children[e])},n.prototype.clear=function(){this.rendered&&(this.unmountEntity(this.rendered),this.rendered=null)},n.prototype.remove=function(){this.clear(),this.events.remove()},n.prototype.mountEntity=function(t,e){t.beforeMount();var n=this.addEntity(t,e);return e.appendChild(n),this.updateEvents(t),t.afterMount(n),n},n.prototype.unmountEntity=function(t){var e=this.getElement(t.id);e&&(t.beforeUnmount(e),e.parentNode&&e.parentNode.removeChild(e),this.unmountChildren(t),this.removeEvents(t),t.afterUnmount(),t.remove(),delete this.elements[t.id])},n.prototype.unmountChildren=function(t){var e=this;o(t.children,function(n,r){t.removeChild(n),e.unmountEntity(r)})},n.prototype.getElement=function(t){return this.elements[t]},n.prototype.updateEvents=function(t){var e=this;this.events.unbind(t.id),o(t.current.nodes,function(n,r){"element"===r.type&&o(r.events,function(r,o){e.events.bind(t.id,n,r,function(e){o.call(t.component,e,t.props,t.state)})})})},n.prototype.removeEvents=function(t){this.events.unbind(t.id)},n.prototype.addEntity=function(t,e){var n=t.render(),r=this.createElement(n.root,n,t,e);return t.setCurrent(n),this.elements[t.id]=r,r},n.prototype.createElement=function(t,e,n,r){var o=e.getPath(t),i=r||document.createDocumentFragment();if(!o)throw new Error("Node does not exist in the entity");if("text"===t.type)return i.appendChild(document.createTextNode(t.data)),i;if("element"===t.type){var s=document.createElement(t.tagName),a=t.children;for(var c in t.attributes)s.setAttribute(c,t.attributes[c]);s.__path__=o,s.__entity__=n.id;for(var u=0,p=a.length;p>u;u++)this.createElement(a[u],e,n,s);return i.appendChild(s),s}if("component"===t.type){var h=n.addChild(o,t.component,t.props);return this.mountEntity(h,i)}}},{"./interactions":31,"component/each":21,"./diff":32}],31:[function(t,e){function n(t){this.el=t,this.handlers={},this.handle=this.handle.bind(this),this.resume()}var r=(t("component/delegate"),t("component/per-frame")),o=t("./keypath"),i=["blur","change","click","contextmenu","copy","cut","dblclick","drag","dragend","dragenter","dragexit","dragleave","dragover","dragstart","drop","focus","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","paste","scroll","submit","touchcancel","touchend","touchmove","touchstart","wheel"];e.exports=n,n.prototype.bind=function(t,e,n,i){o.set(this.handlers,[t,e,n],r(i))},n.prototype.unbind=function(t){delete this.handlers[t]},n.prototype.resume=function(){i.forEach(function(t){this.el.addEventListener(t,this.handle,!0)},this)},n.prototype.pause=function(){i.forEach(function(t){this.el.removeEventListener(t,this.handle,!0)},this)},n.prototype.remove=function(){this.handlers={},this.pause()},n.prototype.handle=function(t){for(var e,n=t.target,r=this.handlers,i=n.__entity__,s=t.type;n&&n.__entity__===i;){var e=o.get(r,[i,n.__path__,s]);if(e){t.delegateTarget=n,e(t);break}n=n.parentNode}}},{"component/delegate":33,"component/per-frame":34,"./keypath":35}],33:[function(t,e,n){var r=t("closest"),o=t("event");n.bind=function(t,e,n,i,s){return o.bind(t,n,function(n){var o=n.target||n.srcElement;n.delegateTarget=r(o,e,!0,t),n.delegateTarget&&i.call(t,n)},s)},n.unbind=function(t,e,n,r){o.unbind(t,e,n,r)}},{closest:36,event:37}],36:[function(t,e){var n=t("matches-selector");e.exports=function(t,e,r,o){for(t=r?{parentNode:t}:t,o=o||document;(t=t.parentNode)&&t!==document;){if(n(t,e))return t;if(t===o)return}}},{"matches-selector":38}],38:[function(t,e){function n(t,e){if(!t||1!==t.nodeType)return!1;if(i)return i.call(t,e);for(var n=r.all(e,t.parentNode),o=0;o<n.length;++o)if(n[o]==t)return!0;return!1}var r=t("query"),o=Element.prototype,i=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.msMatchesSelector||o.oMatchesSelector;e.exports=n},{query:39}],39:[function(t,e,n){function r(t,e){return e.querySelector(t)}n=e.exports=function(t,e){return e=e||document,r(t,e)},n.all=function(t,e){return e=e||document,e.querySelectorAll(t)},n.engine=function(t){if(!t.one)throw new Error(".one callback required");if(!t.all)throw new Error(".all callback required");return r=t.one,n.all=t.all,n}},{}],37:[function(t,e,n){var r=window.addEventListener?"addEventListener":"attachEvent",o=window.removeEventListener?"removeEventListener":"detachEvent",i="addEventListener"!==r?"on":"";n.bind=function(t,e,n,o){return t[r](i+e,n,o||!1),n},n.unbind=function(t,e,n,r){return t[o](i+e,n,r||!1),n}},{}],34:[function(t,e){function n(t){var e,n=!1;return function(){return n?e:(n=!0,r(function(){n=!1}),e=t.apply(this,arguments))}}var r=t("raf");e.exports=n},{raf:40}],40:[function(t,e,n){function r(t){var e=(new Date).getTime(),n=Math.max(0,16-(e-o)),r=setTimeout(t,n);return o=e,r}n=e.exports=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||r;var o=(new Date).getTime(),i=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||window.clearTimeout;n.cancel=function(t){i.call(window,t)}},{}],35:[function(t,e,n){n.get=function(t,e){for(var n=e,r=t;n.length;){var o=n.shift();r=r[o],void 0===r&&(n.length=0)}return r},n.set=function(t,e,n){for(var r=e,o=t,i=r.pop();r.length;){var s=r.shift();o[s]||(o[s]={}),o=o[s]}o[i]=n}},{}],32:[function(t,e){function n(t,e,n,o){var i={entity:t,nextTree:e,renderer:o,rootEl:n,el:n,path:"0",id:t.id,isRoot:!0};return r(t.current.root,e.root,i),i.rootEl}function r(t,e,n){return t.type!==e.type?u(t,e,n):"text"===e.type?o(t,e,n):"component"===e.type?a(t,e,n):"element"===e.type?c(t,e,n):void 0}function o(t,e,n){e.data!==t.data&&(n.el.data=e.data)}function i(t,e,n){for(var o=h(t.children,e.children),i=n.el,s=-1,a=0;a<o.length;a++){s+=1;var c=o[a],u=c[0],f=c[1];null!=u?null!=f?r(u,f,{el:i.childNodes[s],entity:n.entity,nextTree:n.nextTree,renderer:n.renderer,isRoot:!1,path:n.path+"."+s}):(p(u,n),"component"!=u.type&&i.removeChild(i.childNodes[s]),s-=1):n.renderer.createElement(f,n.nextTree,n.entity,i)}}function s(t,e,n){var r=e.attributes,o=t.attributes;for(var i in r){var s=r[i];o[i]&&o[i]===s||n.el.setAttribute(i,s)}for(var a in o)r[a]||n.el.removeAttribute(a)}function a(t,e,n){if(e.component!==t.component)return u(t,e,n);var r=n.entity.getChild(n.path);r.replaceProps(e.props)}function c(t,e,n){return e.tagName!==t.tagName?u(t,e,n):(s(t,e,n),void i(t,e,n))}function u(t,e,n){var r=n.el,o=r.parentNode;p(t,n),r.parentNode&&r.parentNode.removeChild(r);var i=n.renderer.createElement(e,n.nextTree,n.entity);o.insertBefore(i,o.childNodes[t.index]),n.isRoot&&(n.rootEl=i)}function p(t,e){if("component"===t.type){var n=e.entity.current.getPath(t),r=e.entity.removeChild(n);return void e.renderer.unmountEntity(r)}t.children&&t.children.forEach(function(t){p(t,e)},this)}function h(){var t=Array.prototype.slice.call(arguments,0);return t.reduce(function(t,e){return t.length>e.length?t:e},[]).map(function(e,n){return t.map(function(t){return t[n]})})}t("jkroso/equals");e.exports=n},{"jkroso/equals":20}],8:[function(t,e,n){t("sindresorhus/object-assign");n.setState=function(t,e){this.emit("change",t,e)},n.invalidate=function(){this.emit("change",{__force__:!0})},n.render=function(){return null},n.initialState=function(){return{}},n.beforeMount=function(){},n.afterMount=function(){},n.beforeUpdate=function(){},n.afterUpdate=function(){},n.beforeUnmount=function(){},n.afterUnmount=function(){},n.propsChanged=function(){}},{"sindresorhus/object-assign":4}]},{},{1:""}));
0.0.18 / 2015-01-25
==================
* Fixed event delegation
* Added some super basic perf tests
* Fixed issue with scene not removing listeners
0.0.17 / 2015-01-24

@@ -3,0 +10,0 @@ ==================

@@ -127,2 +127,11 @@

/**
* Clear the scene
*/
HTMLRenderer.prototype.remove = function(){
this.clear();
this.events.remove();
};
/**
* Append an entity to an element

@@ -129,0 +138,0 @@ *

@@ -60,3 +60,3 @@

this.handlers = {};
this.handle = handle.bind(this);
this.handle = this.handle.bind(this);
this.resume();

@@ -103,3 +103,3 @@ }

events.forEach(function(name){
this.el.removeEventListener(name, this.handle);
this.el.removeEventListener(name, this.handle, true);
}, this);

@@ -123,9 +123,20 @@ };

function handle(event){
Interactions.prototype.handle = function(event){
var target = event.target;
var handlers = this.handlers;
var fn = keypath.get(this.handlers, [target.__entity__, target.__path__, event.type]);
if (fn) {
fn(event);
var entityId = target.__entity__;
var eventType = event.type;
var fn;
// Walk up the DOM tree and see if there is a handler
// for this event type higher up.
while (target && target.__entity__ === entityId) {
var fn = keypath.get(handlers, [entityId, target.__path__, eventType]);
if (fn) {
event.delegateTarget = target;
fn(event);
break;
}
target = target.parentNode;
}
}
};

@@ -7,3 +7,3 @@

var Emitter = require('component/emitter');
var Signals = require('segmentio/tower');
var Signals = require('segmentio/tower@0.0.1');
var loop = require('./loop');

@@ -132,3 +132,3 @@

this.signals.closeAll();
this.renderer.clear();
this.renderer.remove();
this.off();

@@ -135,0 +135,0 @@ };

{
"name": "deku",
"version": "0.0.17",
"version": "0.0.18",
"repository": "segmentio/deku",

@@ -15,4 +15,5 @@ "description": "Create view components using a virtual DOM",

"minify": "^1.4.8",
"zuul": "~1.16.4"
"zuul": "~1.16.4",
"benchmark": "^1.0.0"
}
}

@@ -7,2 +7,20 @@

var Delegate = component({
render: function (props, state) {
var active = state.active || 0;
var self = this;
var items = [1,2,3].map(function(i){
return dom('li', {
onClick: function(){
self.setState({ active: i })
},
class: { active: active === i }
}, [
dom('a', 'link')
]);
});
return dom('ul', items);
}
});
it('should add click event', function(){

@@ -86,2 +104,69 @@ var count = 0;

});
it('should delegate events', function () {
var scene = Delegate.render(el);
scene.update();
// Click the first link
var first = el.querySelectorAll('a')[0];
trigger(first, 'click');
scene.update();
assert(first.parentNode.classList.contains('active'), 'it should add the active class on the first li');
var second = el.querySelectorAll('a')[1];
trigger(second, 'click');
scene.update();
assert(second.parentNode.classList.contains('active'), 'it should add the active class on the second li');
assert(first.parentNode.classList.contains('active') === false, 'it should remove the active class on the first li');
scene.remove();
});
it('should delegate events on the root', function () {
var DelegateRoot = component({
onClick: function(event){
this.setState({ active: true });
},
render: function (props, state) {
return dom('div', { class: { active: state.active }, onClick: this.onClick }, [
dom('a', 'link')
]);
}
});
var scene = DelegateRoot.render(el);
scene.update();
// Click the link
var first = el.querySelectorAll('a')[0];
trigger(first, 'click');
scene.update();
assert(first.parentNode.classList.contains('active') === true);
scene.remove();
});
it('should set a delegateTarget', function (done) {
var DelegateRoot = component({
onClick: function(event){
assert(event.delegateTarget === el.querySelector('div'));
done();
},
render: function (props, state) {
return dom('div', { onClick: this.onClick }, [
dom('a', 'link')
]);
}
});
var scene = DelegateRoot.render(el);
scene.update();
// Click the link
var first = el.querySelectorAll('a')[0];
trigger(first, 'click');
scene.update();
scene.remove();
});
});

@@ -9,9 +9,6 @@ mocha.setup({globals: ['hasCert']});

// Create a container.
beforeEach(function () {
window.el = document.createElement('div');
document.body.appendChild(window.el);
});
window.el = document.createElement('div');
document.body.appendChild(window.el);

@@ -18,0 +15,0 @@ afterEach(function () {

Sorry, the diff of this file is too big to display

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