diff --git a/README.md b/README.md
index a12eb1a..e337056 100644
--- a/README.md
+++ b/README.md
@@ -17,9 +17,9 @@ $ npm install vue-event-manager
```
### CDN
-Available on [jsdelivr](https://cdn.jsdelivr.net/npm/vue-event-manager@1.0.5) or [unpkg](https://unpkg.com/vue-event-manager@1.0.5).
+Available on [jsdelivr](https://cdn.jsdelivr.net/npm/vue-event-manager@1.0.6) or [unpkg](https://unpkg.com/vue-event-manager@1.0.6).
```html
-
+
```
## Example
diff --git a/dist/vue-event-manager.common.js b/dist/vue-event-manager.common.js
index ab9984c..8e522ae 100644
--- a/dist/vue-event-manager.common.js
+++ b/dist/vue-event-manager.common.js
@@ -1,5 +1,5 @@
/*!
- * vue-event-manager v1.0.5
+ * vue-event-manager v1.0.6
* https://github.com/pagekit/vue-event-manager
* Released under the MIT License.
*/
@@ -26,6 +26,8 @@ function forEach(collection, callback) {
* Array.findIndex() polyfill.
*/
if (!Array.prototype.findIndex) {
+
+ // eslint-disable-next-line
Object.defineProperty(Array.prototype, 'findIndex', {
value: function value(predicate) {
@@ -177,7 +179,7 @@ function initEvents() {
listener = listener.handler;
}
- _events.push(Events.on(event, listener.bind(this$1), priority));
+ _events.push(Events.on(event, bindListener(listener, this$1), priority));
});
});
@@ -185,6 +187,17 @@ function initEvents() {
}
}
+function bindListener(fn, vm) {
+
+ if (typeof fn === 'string') {
+ return function () {
+ return vm[fn].apply(vm, arguments);
+ }
+ }
+
+ return fn.bind(vm);
+}
+
if (typeof window !== 'undefined' && window.Vue) {
window.Vue.use(Events);
}
diff --git a/dist/vue-event-manager.es2015.js b/dist/vue-event-manager.es2015.js
index 9fdda41..595ab26 100644
--- a/dist/vue-event-manager.es2015.js
+++ b/dist/vue-event-manager.es2015.js
@@ -1,5 +1,5 @@
/*!
- * vue-event-manager v1.0.5
+ * vue-event-manager v1.0.6
* https://github.com/pagekit/vue-event-manager
* Released under the MIT License.
*/
@@ -24,6 +24,8 @@ function forEach(collection, callback) {
* Array.findIndex() polyfill.
*/
if (!Array.prototype.findIndex) {
+
+ // eslint-disable-next-line
Object.defineProperty(Array.prototype, 'findIndex', {
value: function value(predicate) {
@@ -175,7 +177,7 @@ function initEvents() {
listener = listener.handler;
}
- _events.push(Events.on(event, listener.bind(this$1), priority));
+ _events.push(Events.on(event, bindListener(listener, this$1), priority));
});
});
@@ -183,6 +185,17 @@ function initEvents() {
}
}
+function bindListener(fn, vm) {
+
+ if (typeof fn === 'string') {
+ return function () {
+ return vm[fn].apply(vm, arguments);
+ }
+ }
+
+ return fn.bind(vm);
+}
+
if (typeof window !== 'undefined' && window.Vue) {
window.Vue.use(Events);
}
diff --git a/dist/vue-event-manager.js b/dist/vue-event-manager.js
index 6ff7808..172c56c 100644
--- a/dist/vue-event-manager.js
+++ b/dist/vue-event-manager.js
@@ -1,5 +1,5 @@
/*!
- * vue-event-manager v1.0.5
+ * vue-event-manager v1.0.6
* https://github.com/pagekit/vue-event-manager
* Released under the MIT License.
*/
@@ -30,6 +30,8 @@ function forEach(collection, callback) {
* Array.findIndex() polyfill.
*/
if (!Array.prototype.findIndex) {
+
+ // eslint-disable-next-line
Object.defineProperty(Array.prototype, 'findIndex', {
value: function value(predicate) {
@@ -181,7 +183,7 @@ function initEvents() {
listener = listener.handler;
}
- _events.push(Events.on(event, listener.bind(this$1), priority));
+ _events.push(Events.on(event, bindListener(listener, this$1), priority));
});
});
@@ -189,6 +191,17 @@ function initEvents() {
}
}
+function bindListener(fn, vm) {
+
+ if (typeof fn === 'string') {
+ return function () {
+ return vm[fn].apply(vm, arguments);
+ }
+ }
+
+ return fn.bind(vm);
+}
+
if (typeof window !== 'undefined' && window.Vue) {
window.Vue.use(Events);
}
diff --git a/dist/vue-event-manager.min.js b/dist/vue-event-manager.min.js
index 5df4d7a..8f83948 100644
--- a/dist/vue-event-manager.min.js
+++ b/dist/vue-event-manager.min.js
@@ -1,7 +1,7 @@
/*!
- * vue-event-manager v1.0.5
+ * vue-event-manager v1.0.6
* https://github.com/pagekit/vue-event-manager
* Released under the MIT License.
*/
-!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.VueEventManager=e()}(this,function(){"use strict";function t(t){return null!==t&&"object"==typeof t}function e(t,e){Object.keys(t||{}).forEach(function(n){e.call(null,t[n],n)})}function n(){var n=this,i=this.$options.events,u=[];i&&(e(i,function(i,s){e(r(i)?i:[i],function(e){var r=0;t(e)&&(r=e.priority,e=e.handler),u.push(o.on(s,e.bind(n),r))})}),this.$on("hook:beforeDestroy",function(){return u.forEach(function(t){return t()})}))}var r=Array.isArray;Array.prototype.findIndex||Object.defineProperty(Array.prototype,"findIndex",{value:function(t){if(null==this)throw new TypeError('"this" is null or not defined');if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var e=Object(this),n=e.length>>>0,r=arguments[1],i=0;i>>0,r=arguments[1],i=0;i