Comparing version 2.0.0 to 2.0.1
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){ | ||
function _toConsumableArray(r){if(Array.isArray(r)){for(var e=0,n=Array(r.length);e<r.length;e++)n[e]=r[e];return n}return Array.from(r)}var morfine=require("morfine"),onload=require("on-load"),assert=require("assert"),INVALID_PROPS=["arguments","caller","length","name","prototype"];function bik(r,e){"function"==typeof r&&(e=r),assert("function"==typeof e,"bik: renderer must be a function");var n=null,o=function(){if(!n){for(var r=arguments.length,t=Array(r),a=0;a<r;a++)t[a]=arguments[a];!function(r){n=morfine(function(){return e.apply(void 0,[o].concat(_toConsumableArray(r)))}),onload(n.el,function(r){o.load&&o.load(r)},function(r){o.unload&&o.unload(r)}),n.beforerender=function(r){o.beforerender&&o.beforerender(r)},n.afterrender=function(r){o.afterrender&&o.afterrender(r)},o.el=n.el,o.r=o.rerender=function(){n.r()}}(t)}return n.el};return Object.keys(r).map(function(e){if(-1!==INVALID_PROPS.indexOf(e))throw new Error('bik: cannot use "'+e+'" as state property name');o[e]=r[e]}),o}module.exports=bik,"undefined"!=typeof window&&(window.bik=bik); | ||
function _toConsumableArray(r){if(Array.isArray(r)){for(var e=0,n=Array(r.length);e<r.length;e++)n[e]=r[e];return n}return Array.from(r)}var morfine=require("morfine"),assert=require("assert"),onload=require("on-load"),OL_KEY_ID=onload.KEY_ID,OL_ATTR_ID=onload.KEY_ATTR,INVALID_PROPS=["arguments","caller","length","name","prototype"];function bik(r,e){"function"==typeof r&&(e=r),assert("function"==typeof e,"bik: renderer must be a function");var n=null,o=function(){if(!n){for(var r=arguments.length,f=Array(r),l=0;l<r;l++)f[l]=arguments[l];!function(r){n=morfine(function(){return e.apply(void 0,[o].concat(_toConsumableArray(r)))},t,a),onload(n.el,i,u,o._bid),Object.defineProperty(o,"el",{get:function(){return n.el}}),o.r=o.rerender=function(){o._olID=n.el.dataset[OL_KEY_ID],n.r()}}(f)}return n.el};function t(r){o.beforerender&&o.beforerender(r)}function a(r){o._olID&&r.setAttribute(OL_ATTR_ID,o._olID),o.afterrender&&o.afterrender(r)}function i(r){o.load&&o.load(r)}function u(r){o.unload&&o.unload(r)}return Object.keys(r).map(function(e){if(-1!==INVALID_PROPS.indexOf(e))throw new Error('bik: cannot use "'+e+'" as state property name');o[e]=r[e]}),o}module.exports=bik,"undefined"!=typeof window&&(window.bik=bik); | ||
},{"assert":2,"morfine":9,"on-load":14}],2:[function(require,module,exports){ | ||
},{"assert":2,"morfine":10,"on-load":15}],2:[function(require,module,exports){ | ||
(function (global){ | ||
@@ -20,5 +20,8 @@ "use strict";function compare(e,t){if(e===t)return 0;for(var r=e.length,n=t.length,i=0,a=Math.min(r,n);i<a;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0}function isBuffer(e){return global.Buffer&&"function"==typeof global.Buffer.isBuffer?global.Buffer.isBuffer(e):!(null==e||!e._isBuffer)}var util=require("util/"),hasOwn=Object.prototype.hasOwnProperty,pSlice=Array.prototype.slice,functionsHaveNames="foo"===function(){}.name;function pToString(e){return Object.prototype.toString.call(e)}function isView(e){return!isBuffer(e)&&("function"==typeof global.ArrayBuffer&&("function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):!!e&&(e instanceof DataView||!!(e.buffer&&e.buffer instanceof ArrayBuffer))))}var assert=module.exports=ok,regex=/\s*function\s+([^\(\s]*)\s*/;function getName(e){if(util.isFunction(e)){if(functionsHaveNames)return e.name;var t=e.toString().match(regex);return t&&t[1]}}function truncate(e,t){return"string"==typeof e?e.length<t?e:e.slice(0,t):e}function inspect(e){if(functionsHaveNames||!util.isFunction(e))return util.inspect(e);var t=getName(e);return"[Function"+(t?": "+t:"")+"]"}function getMessage(e){return truncate(inspect(e.actual),128)+" "+e.operator+" "+truncate(inspect(e.expected),128)}function fail(e,t,r,n,i){throw new assert.AssertionError({message:r,actual:e,expected:t,operator:n,stackStartFunction:i})}function ok(e,t){e||fail(e,!0,t,"==",assert.ok)}function _deepEqual(e,t,r,n){if(e===t)return!0;if(isBuffer(e)&&isBuffer(t))return 0===compare(e,t);if(util.isDate(e)&&util.isDate(t))return e.getTime()===t.getTime();if(util.isRegExp(e)&&util.isRegExp(t))return e.source===t.source&&e.global===t.global&&e.multiline===t.multiline&&e.lastIndex===t.lastIndex&&e.ignoreCase===t.ignoreCase;if(null!==e&&"object"==typeof e||null!==t&&"object"==typeof t){if(isView(e)&&isView(t)&&pToString(e)===pToString(t)&&!(e instanceof Float32Array||e instanceof Float64Array))return 0===compare(new Uint8Array(e.buffer),new Uint8Array(t.buffer));if(isBuffer(e)!==isBuffer(t))return!1;var i=(n=n||{actual:[],expected:[]}).actual.indexOf(e);return-1!==i&&i===n.expected.indexOf(t)||(n.actual.push(e),n.expected.push(t),objEquiv(e,t,r,n))}return r?e===t:e==t}function isArguments(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function objEquiv(e,t,r,n){if(null==e||null==t)return!1;if(util.isPrimitive(e)||util.isPrimitive(t))return e===t;if(r&&Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;var i=isArguments(e),a=isArguments(t);if(i&&!a||!i&&a)return!1;if(i)return _deepEqual(e=pSlice.call(e),t=pSlice.call(t),r);var s,u,o=objectKeys(e),f=objectKeys(t);if(o.length!==f.length)return!1;for(o.sort(),f.sort(),u=o.length-1;u>=0;u--)if(o[u]!==f[u])return!1;for(u=o.length-1;u>=0;u--)if(!_deepEqual(e[s=o[u]],t[s],r,n))return!1;return!0}function notDeepStrictEqual(e,t,r){_deepEqual(e,t,!0)&&fail(e,t,r,"notDeepStrictEqual",notDeepStrictEqual)}function expectedException(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function _tryBlock(e){var t;try{e()}catch(e){t=e}return t}function _throws(e,t,r,n){var i;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=_tryBlock(t),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),e&&!i&&fail(i,r,"Missing expected exception"+n);var a="string"==typeof n,s=!e&&i&&!r;if((!e&&util.isError(i)&&a&&expectedException(i,r)||s)&&fail(i,r,"Got unwanted exception"+n),e&&i&&r&&!expectedException(i,r)||!e&&i)throw i}assert.AssertionError=function(e){this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=getMessage(this),this.generatedMessage=!0);var t=e.stackStartFunction||fail;if(Error.captureStackTrace)Error.captureStackTrace(this,t);else{var r=new Error;if(r.stack){var n=r.stack,i=getName(t),a=n.indexOf("\n"+i);if(a>=0){var s=n.indexOf("\n",a+1);n=n.substring(s+1)}this.stack=n}}},util.inherits(assert.AssertionError,Error),assert.fail=fail,assert.ok=ok,assert.equal=function(e,t,r){e!=t&&fail(e,t,r,"==",assert.equal)},assert.notEqual=function(e,t,r){e==t&&fail(e,t,r,"!=",assert.notEqual)},assert.deepEqual=function(e,t,r){_deepEqual(e,t,!1)||fail(e,t,r,"deepEqual",assert.deepEqual)},assert.deepStrictEqual=function(e,t,r){_deepEqual(e,t,!0)||fail(e,t,r,"deepStrictEqual",assert.deepStrictEqual)},assert.notDeepEqual=function(e,t,r){_deepEqual(e,t,!1)&&fail(e,t,r,"notDeepEqual",assert.notDeepEqual)},assert.notDeepStrictEqual=notDeepStrictEqual,assert.strictEqual=function(e,t,r){e!==t&&fail(e,t,r,"===",assert.strictEqual)},assert.notStrictEqual=function(e,t,r){e===t&&fail(e,t,r,"!==",assert.notStrictEqual)},assert.throws=function(e,t,r){_throws(!0,e,t,r)},assert.doesNotThrow=function(e,t,r){_throws(!1,e,t,r)},assert.ifError=function(e){if(e)throw e};var objectKeys=Object.keys||function(e){var t=[];for(var r in e)hasOwn.call(e,r)&&t.push(r);return t}; | ||
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{"./support/isBuffer":4,"_process":15,"inherits":3}],6:[function(require,module,exports){ | ||
},{"./support/isBuffer":4,"_process":7,"inherits":3}],6:[function(require,module,exports){ | ||
},{}],7:[function(require,module,exports){ | ||
var cachedSetTimeout,cachedClearTimeout,process=module.exports={};function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}function runTimeout(e){if(cachedSetTimeout===setTimeout)return setTimeout(e,0);if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout)return cachedSetTimeout=setTimeout,setTimeout(e,0);try{return cachedSetTimeout(e,0)}catch(t){try{return cachedSetTimeout.call(null,e,0)}catch(t){return cachedSetTimeout.call(this,e,0)}}}function runClearTimeout(e){if(cachedClearTimeout===clearTimeout)return clearTimeout(e);if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout)return cachedClearTimeout=clearTimeout,clearTimeout(e);try{return cachedClearTimeout(e)}catch(t){try{return cachedClearTimeout.call(null,e)}catch(t){return cachedClearTimeout.call(this,e)}}}!function(){try{cachedSetTimeout="function"==typeof setTimeout?setTimeout:defaultSetTimout}catch(e){cachedSetTimeout=defaultSetTimout}try{cachedClearTimeout="function"==typeof clearTimeout?clearTimeout:defaultClearTimeout}catch(e){cachedClearTimeout=defaultClearTimeout}}();var currentQueue,queue=[],draining=!1,queueIndex=-1;function cleanUpNextTick(){draining&¤tQueue&&(draining=!1,currentQueue.length?queue=currentQueue.concat(queue):queueIndex=-1,queue.length&&drainQueue())}function drainQueue(){if(!draining){var e=runTimeout(cleanUpNextTick);draining=!0;for(var t=queue.length;t;){for(currentQueue=queue,queue=[];++queueIndex<t;)currentQueue&¤tQueue[queueIndex].run();queueIndex=-1,t=queue.length}currentQueue=null,draining=!1,runClearTimeout(e)}}function Item(e,t){this.fun=e,this.array=t}function noop(){}process.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];queue.push(new Item(e,t)),1!==queue.length||draining||runTimeout(drainQueue)},Item.prototype.run=function(){this.fun.apply(null,this.array)},process.title="browser",process.browser=!0,process.env={},process.argv=[],process.version="",process.versions={},process.on=noop,process.addListener=noop,process.once=noop,process.off=noop,process.removeListener=noop,process.removeAllListeners=noop,process.emit=noop,process.prependListener=noop,process.prependOnceListener=noop,process.listeners=function(e){return[]},process.binding=function(e){throw new Error("process.binding is not supported")},process.cwd=function(){return"/"},process.chdir=function(e){throw new Error("process.chdir is not supported")},process.umask=function(){return 0}; | ||
},{}],8:[function(require,module,exports){ | ||
(function (global){ | ||
@@ -28,3 +31,3 @@ var doccy,topLevel="undefined"!=typeof global?global:"undefined"!=typeof window?window:{},minDoc=require("min-document");"undefined"!=typeof document?doccy=document:(doccy=topLevel["__GLOBAL_DOCUMENT_CACHE@4"])||(doccy=topLevel["__GLOBAL_DOCUMENT_CACHE@4"]=minDoc),module.exports=doccy; | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{"min-document":6}],8:[function(require,module,exports){ | ||
},{"min-document":6}],9:[function(require,module,exports){ | ||
(function (global){ | ||
@@ -34,23 +37,20 @@ var win;win="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},module.exports=win; | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{}],9:[function(require,module,exports){ | ||
var morph=require("nanomorph"),assert=require("assert");function morfine(e){assert("function"==typeof e,"morfine: renderer must be a function");var r={};return r.el=e(),_checkElement(r.el),r.r=r.rerender=function(){var n=e();_checkElement(n),r.beforerender&&r.beforerender(n);var o=morph(r.el,n);r.afterrender&&r.afterrender(o)},r}function _checkElement(e){if("object"!=typeof e||!e.tagName)throw new Error("morfine: renderer must return a DOM node")}module.exports=morfine; | ||
},{}],10:[function(require,module,exports){ | ||
var morph=require("nanomorph"),assert=require("assert");function morfine(e,r,n){assert("function"==typeof e,"morfine: renderer must be a function");var o={};return o.el=e(),_checkElement(o.el),r&&(o.beforerender=r),n&&(o.afterrender=n,n(o.el)),o.r=o.rerender=function(){var r=o.el,n=e();_checkElement(n),o.beforerender&&o.beforerender(n),morph(r,n),o.afterrender&&o.afterrender(r)},o}function _checkElement(e){if("undefined"!=typeof window&&("object"!=typeof e||!e.tagName))throw new Error("morfine: renderer must return a DOM node")}module.exports=morfine; | ||
},{"assert":2,"nanomorph":11}],10:[function(require,module,exports){ | ||
},{"assert":2,"nanomorph":12}],11:[function(require,module,exports){ | ||
function equal(s,t,r){assert(s==t,r)}function notEqual(s,t,r){assert(s!=t,r)}function notOk(s,t){assert(!s,t)}function assert(s,t){if(!s)throw new Error(t||"AssertionError")}assert.notEqual=notEqual,assert.notOk=notOk,assert.equal=equal,assert.ok=assert,module.exports=assert; | ||
},{}],11:[function(require,module,exports){ | ||
},{}],12:[function(require,module,exports){ | ||
var assert=require("nanoassert"),morph=require("./lib/morph"),TEXT_NODE=3;function nanomorph(e,o,a){return assert.equal(typeof e,"object","nanomorph: oldTree should be an object"),assert.equal(typeof o,"object","nanomorph: newTree should be an object"),a&&a.childrenOnly?(updateChildren(o,e),e):(assert.notEqual(o.nodeType,11,"nanomorph: newTree should have one root node (which is not a DocumentFragment)"),walk(o,e))}function walk(e,o){return o?e?e.isSameNode&&e.isSameNode(o)?o:e.tagName!==o.tagName?e:(morph(e,o),updateChildren(e,o),o):null:e}function updateChildren(e,o){for(var a,n,r,d,l=0,i=0;a=o.childNodes[i],n=e.childNodes[i-l],a||n;i++)if(n)if(a)if(same(n,a))(r=walk(n,a))!==a&&(o.replaceChild(r,a),l++);else{d=null;for(var t=i;t<o.childNodes.length;t++)if(same(o.childNodes[t],n)){d=o.childNodes[t];break}d?((r=walk(n,d))!==d&&l++,o.insertBefore(r,a)):n.id||a.id?(o.insertBefore(n,a),l++):(r=walk(n,a))!==a&&(o.replaceChild(r,a),l++)}else o.appendChild(n),l++;else o.removeChild(a),i--}function same(e,o){return e.id?e.id===o.id:e.isSameNode?e.isSameNode(o):e.tagName===o.tagName&&(e.type===TEXT_NODE&&e.nodeValue===o.nodeValue)}module.exports=nanomorph; | ||
},{"./lib/morph":13,"nanoassert":10}],12:[function(require,module,exports){ | ||
},{"./lib/morph":14,"nanoassert":11}],13:[function(require,module,exports){ | ||
module.exports=["onclick","ondblclick","onmousedown","onmouseup","onmouseover","onmousemove","onmouseout","onmouseenter","onmouseleave","ontouchcancel","ontouchend","ontouchmove","ontouchstart","ondragstart","ondrag","ondragenter","ondragleave","ondragover","ondrop","ondragend","onkeydown","onkeypress","onkeyup","onunload","onabort","onerror","onresize","onscroll","onselect","onchange","onsubmit","onreset","onfocus","onblur","oninput","oncontextmenu","onfocusin","onfocusout"]; | ||
},{}],13:[function(require,module,exports){ | ||
},{}],14:[function(require,module,exports){ | ||
var events=require("./events"),eventsLength=events.length,ELEMENT_NODE=1,TEXT_NODE=3,COMMENT_NODE=8;function morph(e,t){var u=e.nodeType,a=e.nodeName;u===ELEMENT_NODE&©Attrs(e,t),u!==TEXT_NODE&&u!==COMMENT_NODE||t.nodeValue!==e.nodeValue&&(t.nodeValue=e.nodeValue),"INPUT"===a?updateInput(e,t):"OPTION"===a?updateOption(e,t):"TEXTAREA"===a&&updateTextarea(e,t),copyEvents(e,t)}function copyAttrs(e,t){for(var u=t.attributes,a=e.attributes,r=null,n=null,l=null,i=null,o=a.length-1;o>=0;--o)l=(i=a[o]).name,r=i.namespaceURI,n=i.value,r?(l=i.localName||l,t.getAttributeNS(r,l)!==n&&t.setAttributeNS(r,l,n)):t.hasAttribute(l)?t.getAttribute(l)!==n&&("null"===n||"undefined"===n?t.removeAttribute(l):t.setAttribute(l,n)):t.setAttribute(l,n);for(var v=u.length-1;v>=0;--v)!1!==(i=u[v]).specified&&(l=i.name,(r=i.namespaceURI)?(l=i.localName||l,e.hasAttributeNS(r,l)||t.removeAttributeNS(r,l)):e.hasAttributeNS(null,l)||t.removeAttribute(l))}function copyEvents(e,t){for(var u=0;u<eventsLength;u++){var a=events[u];e[a]?t[a]=e[a]:t[a]&&(t[a]=void 0)}}function updateOption(e,t){updateAttribute(e,t,"selected")}function updateInput(e,t){var u=e.value,a=t.value;updateAttribute(e,t,"checked"),updateAttribute(e,t,"disabled"),u!==a&&(t.setAttribute("value",u),t.value=u),"null"===u&&(t.value="",t.removeAttribute("value")),e.hasAttributeNS(null,"value")?"range"===t.type&&(t.value=u):t.removeAttribute("value")}function updateTextarea(e,t){var u=e.value;if(u!==t.value&&(t.value=u),t.firstChild&&t.firstChild.nodeValue!==u){if(""===u&&t.firstChild.nodeValue===t.placeholder)return;t.firstChild.nodeValue=u}}function updateAttribute(e,t,u){e[u]!==t[u]&&(t[u]=e[u],e[u]?t.setAttribute(u,""):t.removeAttribute(u))}module.exports=morph; | ||
},{"./events":12}],14:[function(require,module,exports){ | ||
},{"./events":13}],15:[function(require,module,exports){ | ||
var document=require("global/document"),window=require("global/window"),watch=Object.create(null),KEY_ID="onloadid"+(new Date%9e6).toString(36),KEY_ATTR="data-"+KEY_ID,INDEX=0;if(window&&window.MutationObserver){var observer=new MutationObserver(function(t){if(!(Object.keys(watch).length<1))for(var e=0;e<t.length;e++)t[e].attributeName!==KEY_ATTR?(eachMutation(t[e].removedNodes,function(t,e){document.documentElement.contains(e)||turnoff(t,e)}),eachMutation(t[e].addedNodes,function(t,e){document.documentElement.contains(e)&&turnon(t,e)})):eachAttr(t[e],turnon,turnoff)});observer.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeOldValue:!0,attributeFilter:[KEY_ATTR]})}function turnon(t,e){watch[t][0]&&0===watch[t][2]&&(watch[t][0](e),watch[t][2]=1)}function turnoff(t,e){watch[t][1]&&1===watch[t][2]&&(watch[t][1](e),watch[t][2]=0)}function eachAttr(t,e,n){var o=t.target.getAttribute(KEY_ATTR);sameOrigin(t.oldValue,o)?watch[o]=watch[t.oldValue]:(watch[t.oldValue]&&n(t.oldValue,t.target),watch[o]&&e(o,t.target))}function sameOrigin(t,e){return!(!t||!e)&&watch[t][3]===watch[e][3]}function eachMutation(t,e){for(var n=Object.keys(watch),o=0;o<t.length;o++){if(t[o]&&t[o].getAttribute&&t[o].getAttribute(KEY_ATTR)){var a=t[o].getAttribute(KEY_ATTR);n.forEach(function(n){a===n&&e(n,t[o])})}t[o]&&t[o].childNodes.length>0&&eachMutation(t[o].childNodes,e)}}module.exports=function t(e,n,o,a){return n=n||function(){},o=o||function(){},e.setAttribute(KEY_ATTR,"o"+INDEX),watch["o"+INDEX]=[n,o,0,a||t.caller],INDEX+=1,e},module.exports.KEY_ATTR=KEY_ATTR,module.exports.KEY_ID=KEY_ID; | ||
},{"global/document":7,"global/window":8}],15:[function(require,module,exports){ | ||
var cachedSetTimeout,cachedClearTimeout,process=module.exports={};function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}function runTimeout(e){if(cachedSetTimeout===setTimeout)return setTimeout(e,0);if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout)return cachedSetTimeout=setTimeout,setTimeout(e,0);try{return cachedSetTimeout(e,0)}catch(t){try{return cachedSetTimeout.call(null,e,0)}catch(t){return cachedSetTimeout.call(this,e,0)}}}function runClearTimeout(e){if(cachedClearTimeout===clearTimeout)return clearTimeout(e);if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout)return cachedClearTimeout=clearTimeout,clearTimeout(e);try{return cachedClearTimeout(e)}catch(t){try{return cachedClearTimeout.call(null,e)}catch(t){return cachedClearTimeout.call(this,e)}}}!function(){try{cachedSetTimeout="function"==typeof setTimeout?setTimeout:defaultSetTimout}catch(e){cachedSetTimeout=defaultSetTimout}try{cachedClearTimeout="function"==typeof clearTimeout?clearTimeout:defaultClearTimeout}catch(e){cachedClearTimeout=defaultClearTimeout}}();var currentQueue,queue=[],draining=!1,queueIndex=-1;function cleanUpNextTick(){draining&¤tQueue&&(draining=!1,currentQueue.length?queue=currentQueue.concat(queue):queueIndex=-1,queue.length&&drainQueue())}function drainQueue(){if(!draining){var e=runTimeout(cleanUpNextTick);draining=!0;for(var t=queue.length;t;){for(currentQueue=queue,queue=[];++queueIndex<t;)currentQueue&¤tQueue[queueIndex].run();queueIndex=-1,t=queue.length}currentQueue=null,draining=!1,runClearTimeout(e)}}function Item(e,t){this.fun=e,this.array=t}function noop(){}process.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];queue.push(new Item(e,t)),1!==queue.length||draining||runTimeout(drainQueue)},Item.prototype.run=function(){this.fun.apply(null,this.array)},process.title="browser",process.browser=!0,process.env={},process.argv=[],process.version="",process.versions={},process.on=noop,process.addListener=noop,process.once=noop,process.off=noop,process.removeListener=noop,process.removeAllListeners=noop,process.emit=noop,process.prependListener=noop,process.prependOnceListener=noop,process.listeners=function(e){return[]},process.binding=function(e){throw new Error("process.binding is not supported")},process.cwd=function(){return"/"},process.chdir=function(e){throw new Error("process.chdir is not supported")},process.umask=function(){return 0}; | ||
},{}]},{},[1]); | ||
},{"global/document":8,"global/window":9}]},{},[1]); |
43
index.js
var morfine = require('morfine') | ||
var assert = require('assert') | ||
var onload = require('on-load') | ||
var assert = require('assert') | ||
var OL_KEY_ID = onload.KEY_ID | ||
var OL_ATTR_ID = onload.KEY_ATTR | ||
@@ -31,20 +33,15 @@ var INVALID_PROPS = ['arguments', 'caller', 'length', 'name', 'prototype'] | ||
function _create (args) { | ||
wrapper = morfine(() => renderer(ctx, ...args)) | ||
wrapper = morfine(() => renderer(ctx, ...args), _handleBefore, _handleAfter) | ||
// attach event handlers | ||
onload(wrapper.el, (el) => { | ||
if (ctx.load) ctx.load(el) // load | ||
}, (el) => { | ||
if (ctx.unload) ctx.unload(el) // unload | ||
}) | ||
wrapper.beforerender = (el) => { | ||
if (ctx.beforerender) ctx.beforerender(el) // beforerender | ||
} | ||
wrapper.afterrender = (el) => { | ||
if (ctx.afterrender) ctx.afterrender(el) // afterrender | ||
} | ||
onload(wrapper.el, _handleLoad, _handleUnload, ctx._bid) | ||
// shortcuts to wrapper | ||
ctx.el = wrapper.el | ||
Object.defineProperty(ctx, 'el', { | ||
get: function () { | ||
return wrapper.el | ||
} | ||
}) | ||
ctx.r = ctx.rerender = function () { | ||
ctx._olID = wrapper.el.dataset[OL_KEY_ID] | ||
wrapper.r() | ||
@@ -54,2 +51,20 @@ } | ||
// handlers | ||
function _handleBefore (el) { | ||
if (ctx.beforerender) ctx.beforerender(el) | ||
} | ||
function _handleAfter (el) { | ||
if (ctx._olID) el.setAttribute(OL_ATTR_ID, ctx._olID) | ||
if (ctx.afterrender) ctx.afterrender(el) | ||
} | ||
function _handleLoad (el) { | ||
if (ctx.load) ctx.load(el) // load | ||
} | ||
function _handleUnload (el) { | ||
if (ctx.unload) ctx.unload(el) // unload | ||
} | ||
return ctx | ||
@@ -56,0 +71,0 @@ } |
{ | ||
"name": "bik", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Simple functional components for non-choo & choo environments", | ||
@@ -25,3 +25,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"morfine": "^1.1.0", | ||
"morfine": "^1.2.0", | ||
"on-load": "^4.0.1" | ||
@@ -28,0 +28,0 @@ }, |
@@ -26,3 +26,3 @@ # bik | ||
// non-choo | ||
document.body.appendChild(counter()) | ||
document.body.appendChild(counter(2)) | ||
@@ -29,0 +29,0 @@ // choo |
41
test.js
@@ -58,2 +58,43 @@ var test = require('tape') | ||
test('load', function (t) { | ||
var render = component({ text: 'hello' }, function (ctx) { | ||
return html`<div>${ctx.text}</div>` | ||
}) | ||
var load = fake() | ||
render.load = load | ||
document.body.appendChild(render()) | ||
t.plan(1) | ||
// delay assertion for on-load | ||
setTimeout(function () { | ||
t.equal(load.callCount(), 1, 'was called once') | ||
// cleanup | ||
document.body.removeChild(document.body.childNodes[1]) | ||
}) | ||
}) | ||
test('unload', function (t) { | ||
var render = component({ text: 'hello' }, function (ctx) { | ||
return html`<div>${ctx.text}</div>` | ||
}) | ||
var unload = fake() | ||
render.unload = unload | ||
document.body.appendChild(render()) | ||
t.plan(1) | ||
// delay assertion for on-load | ||
setTimeout(function () { | ||
document.body.removeChild(document.body.childNodes[1]) | ||
// delay assertion for on-load | ||
setTimeout(function () { | ||
t.equal(unload.callCount(), 1, 'was called once') | ||
}) | ||
}) | ||
}) | ||
function greeting (ctx, name) { | ||
@@ -60,0 +101,0 @@ return html` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
32195
264
0
Updatedmorfine@^1.2.0