Added "installed" flag and removed Object.defineProperty

This commit is contained in:
euvl
2017-06-21 20:19:04 +01:00
parent b6c596b514
commit 375ae806ae
4 changed files with 22 additions and 30 deletions

File diff suppressed because one or more lines are too long

15
dist/index.js vendored
View File

@@ -88,10 +88,13 @@ var Plugin = {
install: function install(Vue) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (!this.hasOwnProperty("event")) {
this.event = new Vue();
if (this.installed) {
return;
}
this.installed = true;
this.event = new Vue();
var $modal = {
show: function show(name, params) {
Plugin.event.$emit('toggle', name, true, params);
@@ -104,14 +107,8 @@ var Plugin = {
}
};
Object.defineProperty(Vue.prototype, '$modal', {
get: function get() {
return $modal;
}
});
Vue.prototype.$modal = $modal;
Vue.component('modal', _Modal2.default);
return null;
}
};

15
dist/ssr.index.js vendored
View File

@@ -88,10 +88,13 @@ var Plugin = {
install: function install(Vue) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (!this.hasOwnProperty("event")) {
this.event = new Vue();
if (this.installed) {
return;
}
this.installed = true;
this.event = new Vue();
var $modal = {
show: function show(name, params) {
Plugin.event.$emit('toggle', name, true, params);
@@ -104,14 +107,8 @@ var Plugin = {
}
};
Object.defineProperty(Vue.prototype, '$modal', {
get: function get() {
return $modal;
}
});
Vue.prototype.$modal = $modal;
Vue.component('modal', _Modal2.default);
return null;
}
};

View File

@@ -2,10 +2,13 @@ import Modal from './Modal.vue'
const Plugin = {
install (Vue, options = {}) {
if (!this.hasOwnProperty("event")) {
this.event = new Vue()
if (this.installed) {
return
}
this.installed = true
this.event = new Vue()
const $modal = {
show (name, params) {
Plugin.event.$emit('toggle', name, true, params)
@@ -20,12 +23,8 @@ const Plugin = {
}
}
Object.defineProperty(Vue.prototype, '$modal', {
get: () => $modal
})
Vue.prototype.$modal = $modal
Vue.component('modal', Modal)
return null
}
}