[improvement] optimize popup mixin (#1979)
This commit is contained in:
@@ -10,23 +10,23 @@ const defaultConfig = {
|
||||
export default {
|
||||
open(vm, config) {
|
||||
/* istanbul ignore next */
|
||||
if (!context.stack.some(item => item.vm._popupId === vm._popupId)) {
|
||||
if (!context.stack.some(item => item.vm === vm)) {
|
||||
const el = vm.$el;
|
||||
const targetNode = el && el.parentNode && el.parentNode.nodeType !== 11 ? el.parentNode : document.body;
|
||||
context.stack.push({ vm, config, targetNode });
|
||||
const target = el && el.parentNode ? el.parentNode : document.body;
|
||||
context.stack.push({ vm, config, target });
|
||||
this.update();
|
||||
};
|
||||
},
|
||||
|
||||
close(id) {
|
||||
close(vm) {
|
||||
const { stack } = context;
|
||||
|
||||
if (stack.length) {
|
||||
if (context.top.vm._popupId === id) {
|
||||
if (context.top.vm === vm) {
|
||||
stack.pop();
|
||||
this.update();
|
||||
} else {
|
||||
context.stack = stack.filter(item => item.vm._popupId !== id);
|
||||
context.stack = stack.filter(item => item.vm !== vm);
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -48,9 +48,9 @@ export default {
|
||||
}
|
||||
|
||||
if (context.top) {
|
||||
const { targetNode, config } = context.top;
|
||||
const { target, config } = context.top;
|
||||
|
||||
targetNode.appendChild(modal.$el);
|
||||
target.appendChild(modal.$el);
|
||||
Object.assign(modal, {
|
||||
...defaultConfig,
|
||||
...config,
|
||||
|
||||
Reference in New Issue
Block a user