Skip to content

Commit 57148c9

Browse files
committed
fix promise and version++
1 parent f838ba6 commit 57148c9

File tree

2 files changed

+38
-43
lines changed

2 files changed

+38
-43
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vuejs-modal",
3-
"version": "0.0.3",
3+
"version": "0.0.4",
44
"description": "A simple、highly customizable vue modal plugin.",
55
"main": "dist/vuejs-modal.common.js",
66
"module": "dist/vuejs-modal.esm.js",

src/index.js

Lines changed: 37 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
// Object.assign Polyfill
22
if (typeof Object.assign != 'function') {
3-
Object.assign = function(target) {
4-
'use strict';
5-
if (target == null) {
6-
throw new TypeError('Cannot convert undefined or null to object');
7-
}
3+
Object.assign = function (target) {
4+
'use strict';
5+
if (target == null) {
6+
throw new TypeError('Cannot convert undefined or null to object');
7+
}
88

9-
target = Object(target);
10-
for (var index = 1; index < arguments.length; index++) {
11-
var source = arguments[index];
12-
if (source != null) {
13-
for (var key in source) {
14-
if (Object.prototype.hasOwnProperty.call(source, key)) {
15-
target[key] = source[key];
16-
}
9+
target = Object(target);
10+
for (var index = 1; index < arguments.length; index++) {
11+
var source = arguments[index];
12+
if (source != null) {
13+
for (var key in source) {
14+
if (Object.prototype.hasOwnProperty.call(source, key)) {
15+
target[key] = source[key];
16+
}
17+
}
18+
}
1719
}
18-
}
19-
}
20-
return target;
21-
};
20+
return target;
21+
};
2222
}
2323

2424
// Promise Polyfill Auto
25-
require('es6-promise').polyfill();
26-
require('es6-promise/auto');
25+
var Promise = require('es6-promise').Promise;
2726

2827
var Modal = {
2928
/**
@@ -73,30 +72,26 @@ var Modal = {
7372
*/
7473
modals[v] = options => {
7574
return new Promise((resolve, reject) => {
76-
try {
77-
new Vue({
78-
render: h => h(defaultOptions.modals[v], {
79-
props: options,
80-
style: Object.assign(defaultOptions.style, {
81-
zIndex: this.zIndex
82-
}),
83-
on: {
84-
$ok: function ($el, info) {
85-
$el.remove()
86-
resolve(info)
87-
},
88-
$cancel: function ($el, info) {
89-
$el.remove()
90-
reject(info)
91-
}
75+
new Vue({
76+
render: h => h(defaultOptions.modals[v], {
77+
props: options,
78+
style: Object.assign(defaultOptions.style, {
79+
zIndex: this.zIndex
80+
}),
81+
on: {
82+
$ok: function ($el, info) {
83+
$el.remove()
84+
resolve(info)
85+
},
86+
$cancel: function ($el, info) {
87+
$el.remove()
88+
reject(info)
9289
}
93-
})
94-
}).$mount('#' + defaultOptions.id)
95-
this.zIndex += 5;
96-
this.init(defaultOptions.id);
97-
} catch (error) {
98-
console.error('vuejs-modal', error)
99-
}
90+
}
91+
})
92+
}).$mount('#' + defaultOptions.id)
93+
this.zIndex += 5;
94+
this.init(defaultOptions.id);
10095

10196
})
10297
}

0 commit comments

Comments
 (0)