Skip to content

Commit c30e0d5

Browse files
committed
build
1 parent 7283a95 commit c30e0d5

File tree

2 files changed

+84
-10
lines changed

2 files changed

+84
-10
lines changed

cjs/index.js

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,52 @@ var EventManagment = /** @class */ (function (_super) {
1515
__extends(EventManagment, _super);
1616
function EventManagment() {
1717
var _this = _super !== null && _super.apply(this, arguments) || this;
18-
_this.$emit = _this.emit;
19-
_this.$on = _this.on;
20-
_this.$off = _this.off;
21-
_this.$once = _this.$once;
18+
_this.$emit = _super.prototype.emit;
19+
_this.$on = _super.prototype.on;
20+
_this.$off = _super.prototype.off;
21+
_this.$once = _super.prototype.once;
2222
return _this;
2323
}
2424
return EventManagment;
2525
}(js_simple_events_1.default));
2626
var eventsPlugins = function (Vue) {
27-
Vue.prototype.$events = new EventManagment();
27+
var eventManagement = new EventManagment();
28+
Object.defineProperties(Vue.prototype, {
29+
'$events': {
30+
get: function () {
31+
return eventManagement;
32+
}
33+
}
34+
});
35+
Vue.mixin({
36+
beforeCreate: function () {
37+
var $this = this;
38+
var evts = $this.$options.on;
39+
if (evts) {
40+
$this.$options.$setEvents = {};
41+
for (var k in evts) {
42+
$this.$options.$setEvents[k] = ~evts[k].name.indexOf('bound ') ? evts[k] : evts[k].bind(this);
43+
}
44+
}
45+
},
46+
created: function () {
47+
var $this = this;
48+
var evts = $this.$options.$setEvents;
49+
if (evts) {
50+
for (var k in evts) {
51+
Vue.prototype.$events.on(k, evts[k]);
52+
}
53+
}
54+
},
55+
beforeDestroy: function () {
56+
var $this = this;
57+
var evts = $this.$options.$setEvents;
58+
if (evts) {
59+
for (var k in evts) {
60+
Vue.prototype.$events.off(k, evts[k]);
61+
}
62+
}
63+
}
64+
});
2865
};
2966
exports.default = eventsPlugins;

es5/index.js

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,52 @@ var EventManagment = /** @class */ (function (_super) {
1313
__extends(EventManagment, _super);
1414
function EventManagment() {
1515
var _this = _super !== null && _super.apply(this, arguments) || this;
16-
_this.$emit = _this.emit;
17-
_this.$on = _this.on;
18-
_this.$off = _this.off;
19-
_this.$once = _this.$once;
16+
_this.$emit = _super.prototype.emit;
17+
_this.$on = _super.prototype.on;
18+
_this.$off = _super.prototype.off;
19+
_this.$once = _super.prototype.once;
2020
return _this;
2121
}
2222
return EventManagment;
2323
}(JSEventManagment));
2424
var eventsPlugins = function (Vue) {
25-
Vue.prototype.$events = new EventManagment();
25+
var eventManagement = new EventManagment();
26+
Object.defineProperties(Vue.prototype, {
27+
'$events': {
28+
get: function () {
29+
return eventManagement;
30+
}
31+
}
32+
});
33+
Vue.mixin({
34+
beforeCreate: function () {
35+
var $this = this;
36+
var evts = $this.$options.on;
37+
if (evts) {
38+
$this.$options.$setEvents = {};
39+
for (var k in evts) {
40+
$this.$options.$setEvents[k] = ~evts[k].name.indexOf('bound ') ? evts[k] : evts[k].bind(this);
41+
}
42+
}
43+
},
44+
created: function () {
45+
var $this = this;
46+
var evts = $this.$options.$setEvents;
47+
if (evts) {
48+
for (var k in evts) {
49+
Vue.prototype.$events.on(k, evts[k]);
50+
}
51+
}
52+
},
53+
beforeDestroy: function () {
54+
var $this = this;
55+
var evts = $this.$options.$setEvents;
56+
if (evts) {
57+
for (var k in evts) {
58+
Vue.prototype.$events.off(k, evts[k]);
59+
}
60+
}
61+
}
62+
});
2663
};
2764
export default eventsPlugins;

0 commit comments

Comments
 (0)