diff --git a/CHANGELOG.md b/CHANGELOG.md index 19299b4..69be46a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ # Freezer Changelog + +###v0.12.1 +* Recovers trigger method deleted by default + ###v0.12.0 * Adds a warning mechanism to detect errors quickly. * Adds warning for setting non numeric attributes for arrays. diff --git a/build/freezer.js b/build/freezer.js index df74a9f..9ee3960 100644 --- a/build/freezer.js +++ b/build/freezer.js @@ -1,4 +1,4 @@ -/* freezer-js v0.12.0 (13-5-2017) +/* freezer-js v0.12.1 (18-5-2017) * https://github.com/arqex/freezer * By arqex * License: MIT @@ -1033,7 +1033,7 @@ var Freezer = function( initialValue, options ) { hub = {} ; - Utils.each(['on', 'off', 'once', 'emit'], function( method ){ + Utils.each(['on', 'off', 'once', 'emit', 'trigger'], function( method ){ var attrs = {}; attrs[ method ] = listener[method].bind(listener); Utils.addNE( me, attrs ); diff --git a/build/freezer.min.js b/build/freezer.min.js index d5e3e90..cb6b65f 100644 --- a/build/freezer.min.js +++ b/build/freezer.min.js @@ -1,6 +1,6 @@ /* -freezer-js v0.12.0 +freezer-js v0.12.1 https://github.com/arqex/freezer MIT: https://github.com/arqex/freezer/raw/master/LICENSE */ -!function(e,t){"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?module.exports=t():e.Freezer=t()}(this,function(){"use strict";var e="undefined"!=typeof e?e:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t={extend:function(e,t){for(var n in t)e[n]=t[n];return e},createNonEnumerable:function(e,t){var n={};for(var r in e)n[r]={value:e[r]};return Object.create(t||{},n)},error:function(e){var t=new Error(e);if(console)return console.error(t);throw t},each:function(e,t){var n,r,i;if(e&&e.constructor===Array)for(n=0,r=e.length;n=0;n--)r[n].callback===t&&r.splice(n,1)}return this},emit:function(e){var t,n,s,a,f=[].slice.call(arguments,1),c=this._events[e]||[],u=[],h=o.indexOf(e)!==-1;for(h||this.emit.apply(this,[r,e].concat(f)),t=0;t=0;t--)c.splice(u[t],1);return h||this.emit.apply(this,[i,e].concat(f)),s},trigger:function(){return t.warn(!1,"Method `trigger` is deprecated and will be removed from freezer in upcoming releases. Please use `emit`."),this.emit.apply(this,arguments)}},a=t.createNonEnumerable(s),f={freeze:function(e,r){if(e&&e.__)return e;var i=this,o=n.clone(e);return t.addNE(o,{__:{listener:!1,parents:[],store:r}}),t.each(e,function(e,n){t.isLeaf(e,r.freezeInstances)||(e=i.freeze(e,r)),e&&e.__&&i.addParent(e,o),o[n]=e}),r.freezeFn(o),o},merge:function(e,n){var r=e.__,i=r.trans,n=t.extend({},n);if(i){for(var o in n)i[o]=n[o];return e}var s,a,f,c=this,u=this.copyMeta(e),h=r.store;t.each(e,function(r,i){return f=r&&r.__,f&&c.removeParent(r,e),(s=n[i])?(t.isLeaf(s,h.freezeInstances)||(s=c.freeze(s,h)),s&&s.__&&c.addParent(s,u),delete n[i],void(u[i]=s)):(f&&c.addParent(r,u),u[i]=r)});for(a in n)s=n[a],t.isLeaf(s,h.freezeInstances)||(s=c.freeze(s,h)),s&&s.__&&c.addParent(s,u),u[a]=s;return r.store.freezeFn(u),this.refreshParents(e,u),u},replace:function(e,n){var r=this,i=e.__,o=n;return t.isLeaf(n,i.store.freezeInstances)||(o=r.freeze(n,i.store),o.__.parents=i.parents,o.__.updateRoot=i.updateRoot,i.listener&&(o.__.listener=i.listener)),o&&this.fixChildren(o,e),this.refreshParents(e,o),o},remove:function(e,n){var r=e.__.trans;if(r){for(var i=n.length-1;i>=0;i--)delete r[n[i]];return e}var o,s=this,a=this.copyMeta(e);return t.each(e,function(t,r){o=t&&t.__,o&&s.removeParent(t,e),n.indexOf(r)===-1&&(o&&s.addParent(t,a),a[r]=t)}),e.__.store.freezeFn(a),this.refreshParents(e,a),a},splice:function(e,n){var r=e.__,i=r.trans;if(i)return i.splice.apply(i,n),e;var o,s=this,a=this.copyMeta(e),f=n[0],c=f+n[1];if(t.each(e,function(t,n){t&&t.__&&(s.removeParent(t,e),(n=c)&&s.addParent(t,a)),a[n]=t}),n.length>1)for(var u=n.length-1;u>=2;u--)o=n[u],t.isLeaf(o,r.store.freezeInstances)||(o=this.freeze(o,r.store)),o&&o.__&&this.addParent(o,a),n[u]=o;return Array.prototype.splice.apply(a,n),r.store.freezeFn(a),this.refreshParents(e,a),a},transact:function(e){var n,r=this,i=e.__.trans;return i?i:(n=e.constructor===Array?[]:{},t.each(e,function(e,t){n[t]=e}),e.__.trans=n,t.nextTick(function(){e.__.trans&&r.run(e)}),n)},run:function(e){var n=this,r=e.__.trans;if(!r)return e;t.each(r,function(t,r){t&&t.__&&n.removeParent(t,e)}),delete e.__.trans;var i=this.replace(e,r);return i},pivot:function(e){return e.__.pivot=1,this.unpivot(e),e},unpivot:function(e){t.nextTick(function(){e.__.pivot=0})},refresh:function(e,n,r){var i=this,o=e.__.trans,s=0;if(o)return t.each(o,function(t,a){s||t===n&&(o[a]=r,s=1,r&&r.__&&i.addParent(r,e))}),e;var a,f=this.copyMeta(e);t.each(e,function(t,o){t===n&&(t=r),t&&(a=t.__)&&(i.removeParent(t,e),i.addParent(t,f)),f[o]=t}),e.__.store.freezeFn(f),this.refreshParents(e,f)},fixChildren:function(e,n){var r=this;t.each(e,function(t){if(t&&t.__){if(r.fixChildren(t),1===t.__.parents.length)return t.__.parents=[e];n&&r.removeParent(t,n),r.addParent(t,e)}})},copyMeta:function(e){var r=n.clone(e),i=e.__;return t.addNE(r,{__:{store:i.store,updateRoot:i.updateRoot,listener:i.listener,parents:i.parents.slice(0),trans:i.trans,pivot:i.pivot}}),i.pivot&&this.unpivot(r),r},refreshParents:function(e,t){var n,r=e.__,i=r.parents.length;if(e.__.updateRoot&&e.__.updateRoot(e,t),t&&this.emit(e,"update",t,r.store.live),i)for(n=i-1;n>=0;n--)this.refresh(r.parents[n],e,t)},removeParent:function(e,t){var n=e.__.parents,r=n.indexOf(t);r!==-1&&n.splice(r,1)},addParent:function(e,t){var n=e.__.parents,r=n.indexOf(t);r===-1&&(n[n.length]=t)},emit:function(e,n,r,i){var o=e.__.listener;if(o){var s=o.ticking;if(i)return void((s||r)&&(o.ticking=0,o.emit(n,s||r,e)));o.ticking=r,o.prevState||(o.prevState=e),s||t.nextTick(function(){if(o.ticking){var t=o.ticking;o.prevState;o.ticking=0,o.prevState=0,o.emit(n,t,e)}})}},createListener:function(e){var t=e.__.listener;return t||(t=Object.create(a,{_events:{value:{},writable:!0}}),e.__.listener=t),t}};n.init(f);var c=function(e,n){var r,i,o=this,s=n||{},a={live:s.live||!1,freezeInstances:s.freezeInstances||!1},c=[],u=0,h=function(e){var t,n=e.__;if(n.listener){var r=n.listener.prevState||e;n.listener.prevState=0,f.emit(r,"update",e,!0)}for(t=0;t=0;n--)r[n].callback===t&&r.splice(n,1)}return this},emit:function(e){var t,n,s,a,f=[].slice.call(arguments,1),c=this._events[e]||[],u=[],h=o.indexOf(e)!==-1;for(h||this.emit.apply(this,[r,e].concat(f)),t=0;t=0;t--)c.splice(u[t],1);return h||this.emit.apply(this,[i,e].concat(f)),s},trigger:function(){return t.warn(!1,"Method `trigger` is deprecated and will be removed from freezer in upcoming releases. Please use `emit`."),this.emit.apply(this,arguments)}},a=t.createNonEnumerable(s),f={freeze:function(e,r){if(e&&e.__)return e;var i=this,o=n.clone(e);return t.addNE(o,{__:{listener:!1,parents:[],store:r}}),t.each(e,function(e,n){t.isLeaf(e,r.freezeInstances)||(e=i.freeze(e,r)),e&&e.__&&i.addParent(e,o),o[n]=e}),r.freezeFn(o),o},merge:function(e,n){var r=e.__,i=r.trans,n=t.extend({},n);if(i){for(var o in n)i[o]=n[o];return e}var s,a,f,c=this,u=this.copyMeta(e),h=r.store;t.each(e,function(r,i){return f=r&&r.__,f&&c.removeParent(r,e),(s=n[i])?(t.isLeaf(s,h.freezeInstances)||(s=c.freeze(s,h)),s&&s.__&&c.addParent(s,u),delete n[i],void(u[i]=s)):(f&&c.addParent(r,u),u[i]=r)});for(a in n)s=n[a],t.isLeaf(s,h.freezeInstances)||(s=c.freeze(s,h)),s&&s.__&&c.addParent(s,u),u[a]=s;return r.store.freezeFn(u),this.refreshParents(e,u),u},replace:function(e,n){var r=this,i=e.__,o=n;return t.isLeaf(n,i.store.freezeInstances)||(o=r.freeze(n,i.store),o.__.parents=i.parents,o.__.updateRoot=i.updateRoot,i.listener&&(o.__.listener=i.listener)),o&&this.fixChildren(o,e),this.refreshParents(e,o),o},remove:function(e,n){var r=e.__.trans;if(r){for(var i=n.length-1;i>=0;i--)delete r[n[i]];return e}var o,s=this,a=this.copyMeta(e);return t.each(e,function(t,r){o=t&&t.__,o&&s.removeParent(t,e),n.indexOf(r)===-1&&(o&&s.addParent(t,a),a[r]=t)}),e.__.store.freezeFn(a),this.refreshParents(e,a),a},splice:function(e,n){var r=e.__,i=r.trans;if(i)return i.splice.apply(i,n),e;var o,s=this,a=this.copyMeta(e),f=n[0],c=f+n[1];if(t.each(e,function(t,n){t&&t.__&&(s.removeParent(t,e),(n=c)&&s.addParent(t,a)),a[n]=t}),n.length>1)for(var u=n.length-1;u>=2;u--)o=n[u],t.isLeaf(o,r.store.freezeInstances)||(o=this.freeze(o,r.store)),o&&o.__&&this.addParent(o,a),n[u]=o;return Array.prototype.splice.apply(a,n),r.store.freezeFn(a),this.refreshParents(e,a),a},transact:function(e){var n,r=this,i=e.__.trans;return i?i:(n=e.constructor===Array?[]:{},t.each(e,function(e,t){n[t]=e}),e.__.trans=n,t.nextTick(function(){e.__.trans&&r.run(e)}),n)},run:function(e){var n=this,r=e.__.trans;if(!r)return e;t.each(r,function(t,r){t&&t.__&&n.removeParent(t,e)}),delete e.__.trans;var i=this.replace(e,r);return i},pivot:function(e){return e.__.pivot=1,this.unpivot(e),e},unpivot:function(e){t.nextTick(function(){e.__.pivot=0})},refresh:function(e,n,r){var i=this,o=e.__.trans,s=0;if(o)return t.each(o,function(t,a){s||t===n&&(o[a]=r,s=1,r&&r.__&&i.addParent(r,e))}),e;var a,f=this.copyMeta(e);t.each(e,function(t,o){t===n&&(t=r),t&&(a=t.__)&&(i.removeParent(t,e),i.addParent(t,f)),f[o]=t}),e.__.store.freezeFn(f),this.refreshParents(e,f)},fixChildren:function(e,n){var r=this;t.each(e,function(t){if(t&&t.__){if(r.fixChildren(t),1===t.__.parents.length)return t.__.parents=[e];n&&r.removeParent(t,n),r.addParent(t,e)}})},copyMeta:function(e){var r=n.clone(e),i=e.__;return t.addNE(r,{__:{store:i.store,updateRoot:i.updateRoot,listener:i.listener,parents:i.parents.slice(0),trans:i.trans,pivot:i.pivot}}),i.pivot&&this.unpivot(r),r},refreshParents:function(e,t){var n,r=e.__,i=r.parents.length;if(e.__.updateRoot&&e.__.updateRoot(e,t),t&&this.emit(e,"update",t,r.store.live),i)for(n=i-1;n>=0;n--)this.refresh(r.parents[n],e,t)},removeParent:function(e,t){var n=e.__.parents,r=n.indexOf(t);r!==-1&&n.splice(r,1)},addParent:function(e,t){var n=e.__.parents,r=n.indexOf(t);r===-1&&(n[n.length]=t)},emit:function(e,n,r,i){var o=e.__.listener;if(o){var s=o.ticking;if(i)return void((s||r)&&(o.ticking=0,o.emit(n,s||r,e)));o.ticking=r,o.prevState||(o.prevState=e),s||t.nextTick(function(){if(o.ticking){var t=o.ticking;o.prevState;o.ticking=0,o.prevState=0,o.emit(n,t,e)}})}},createListener:function(e){var t=e.__.listener;return t||(t=Object.create(a,{_events:{value:{},writable:!0}}),e.__.listener=t),t}};n.init(f);var c=function(e,n){var r,i,o=this,s=n||{},a={live:s.live||!1,freezeInstances:s.freezeInstances||!1},c=[],u=0,h=function(e){var t,n=e.__;if(n.listener){var r=n.listener.prevState||e;n.listener.prevState=0,f.emit(r,"update",e,!0)}for(t=0;t