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

Commit a685ab7

Browse files
author
Steffan
committed
v1.0.6
1 parent 1643e73 commit a685ab7

File tree

6 files changed

+50
-11
lines changed

6 files changed

+50
-11
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ $ npm install vue-event-manager
1717
```
1818

1919
### CDN
20-
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).
20+
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).
2121
```html
22-
<script src="https://cdn.jsdelivr.net/npm/vue-event-manager@1.0.5"></script>
22+
<script src="https://cdn.jsdelivr.net/npm/vue-event-manager@1.0.6"></script>
2323
```
2424

2525
## Example

dist/vue-event-manager.common.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* vue-event-manager v1.0.5
2+
* vue-event-manager v1.0.6
33
* https://github.com/pagekit/vue-event-manager
44
* Released under the MIT License.
55
*/
@@ -26,6 +26,8 @@ function forEach(collection, callback) {
2626
* Array.findIndex() polyfill.
2727
*/
2828
if (!Array.prototype.findIndex) {
29+
30+
// eslint-disable-next-line
2931
Object.defineProperty(Array.prototype, 'findIndex', {
3032

3133
value: function value(predicate) {
@@ -177,14 +179,25 @@ function initEvents() {
177179
listener = listener.handler;
178180
}
179181

180-
_events.push(Events.on(event, listener.bind(this$1), priority));
182+
_events.push(Events.on(event, bindListener(listener, this$1), priority));
181183
});
182184
});
183185

184186
this.$on('hook:beforeDestroy', function () { return _events.forEach(function (off) { return off(); }); });
185187
}
186188
}
187189

190+
function bindListener(fn, vm) {
191+
192+
if (typeof fn === 'string') {
193+
return function () {
194+
return vm[fn].apply(vm, arguments);
195+
}
196+
}
197+
198+
return fn.bind(vm);
199+
}
200+
188201
if (typeof window !== 'undefined' && window.Vue) {
189202
window.Vue.use(Events);
190203
}

dist/vue-event-manager.es2015.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* vue-event-manager v1.0.5
2+
* vue-event-manager v1.0.6
33
* https://github.com/pagekit/vue-event-manager
44
* Released under the MIT License.
55
*/
@@ -24,6 +24,8 @@ function forEach(collection, callback) {
2424
* Array.findIndex() polyfill.
2525
*/
2626
if (!Array.prototype.findIndex) {
27+
28+
// eslint-disable-next-line
2729
Object.defineProperty(Array.prototype, 'findIndex', {
2830

2931
value: function value(predicate) {
@@ -175,14 +177,25 @@ function initEvents() {
175177
listener = listener.handler;
176178
}
177179

178-
_events.push(Events.on(event, listener.bind(this$1), priority));
180+
_events.push(Events.on(event, bindListener(listener, this$1), priority));
179181
});
180182
});
181183

182184
this.$on('hook:beforeDestroy', function () { return _events.forEach(function (off) { return off(); }); });
183185
}
184186
}
185187

188+
function bindListener(fn, vm) {
189+
190+
if (typeof fn === 'string') {
191+
return function () {
192+
return vm[fn].apply(vm, arguments);
193+
}
194+
}
195+
196+
return fn.bind(vm);
197+
}
198+
186199
if (typeof window !== 'undefined' && window.Vue) {
187200
window.Vue.use(Events);
188201
}

dist/vue-event-manager.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* vue-event-manager v1.0.5
2+
* vue-event-manager v1.0.6
33
* https://github.com/pagekit/vue-event-manager
44
* Released under the MIT License.
55
*/
@@ -30,6 +30,8 @@ function forEach(collection, callback) {
3030
* Array.findIndex() polyfill.
3131
*/
3232
if (!Array.prototype.findIndex) {
33+
34+
// eslint-disable-next-line
3335
Object.defineProperty(Array.prototype, 'findIndex', {
3436

3537
value: function value(predicate) {
@@ -181,14 +183,25 @@ function initEvents() {
181183
listener = listener.handler;
182184
}
183185

184-
_events.push(Events.on(event, listener.bind(this$1), priority));
186+
_events.push(Events.on(event, bindListener(listener, this$1), priority));
185187
});
186188
});
187189

188190
this.$on('hook:beforeDestroy', function () { return _events.forEach(function (off) { return off(); }); });
189191
}
190192
}
191193

194+
function bindListener(fn, vm) {
195+
196+
if (typeof fn === 'string') {
197+
return function () {
198+
return vm[fn].apply(vm, arguments);
199+
}
200+
}
201+
202+
return fn.bind(vm);
203+
}
204+
192205
if (typeof window !== 'undefined' && window.Vue) {
193206
window.Vue.use(Events);
194207
}

dist/vue-event-manager.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-event-manager",
3-
"version": "1.0.5",
3+
"version": "1.0.6",
44
"main": "dist/vue-event-manager.common.js",
55
"module": "dist/vue-event-manager.es2015.js",
66
"unpkg": "dist/vue-event-manager.min.js",

0 commit comments

Comments
 (0)