Skip to content
This repository was archived by the owner on Dec 1, 2023. It is now read-only.

Commit 1643e73

Browse files
author
Steffan
committed
update dependencies, cleanup
1 parent c6da545 commit 1643e73

File tree

3 files changed

+442
-704
lines changed

3 files changed

+442
-704
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"karma-safari-launcher": "^1.0.0",
3939
"karma-webpack": "^2.0.9",
4040
"replace-in-file": "^3.1.0",
41-
"rollup": "^0.52.3",
41+
"rollup": "^0.55.1",
4242
"rollup-plugin-buble": "^0.18.0",
4343
"uglify-js": "^3.2.2",
4444
"vue": "^2.5.13",

src/index.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ function initEvents() {
2626
if (events) {
2727

2828
forEach(events, (listeners, event) => {
29-
3029
forEach(isArray(listeners) ? listeners : [listeners], listener => {
3130

3231
var priority = 0;
@@ -36,19 +35,25 @@ function initEvents() {
3635
listener = listener.handler;
3736
}
3837

39-
if (typeof listener === 'string') {
40-
const name = listener;
41-
listener = (...args) => this[name].apply(this, args);
42-
}
43-
44-
_events.push(Events.on(event, listener.bind(this), priority));
38+
_events.push(Events.on(event, bindListener(listener, this), priority));
4539
});
4640
});
4741

4842
this.$on('hook:beforeDestroy', () => _events.forEach(off => off()));
4943
}
5044
}
5145

46+
function bindListener(fn, vm) {
47+
48+
if (typeof fn === 'string') {
49+
return function () {
50+
return vm[fn].apply(vm, arguments);
51+
}
52+
}
53+
54+
return fn.bind(vm);
55+
}
56+
5257
if (typeof window !== 'undefined' && window.Vue) {
5358
window.Vue.use(Events);
5459
}

0 commit comments

Comments
 (0)