mirror of
https://github.com/youzan/vant.git
synced 2025-10-19 01:54:48 +00:00
[bugfix] Toast: edundant instance when sync called multil times
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import Vue from 'vue';
|
||||
import VueToast from './Toast';
|
||||
import { isObj, isServer, isInDocument } from '../utils';
|
||||
import { isObj, isServer } from '../utils';
|
||||
|
||||
const defaultOptions = {
|
||||
type: 'text',
|
||||
@@ -38,7 +38,7 @@ function createInstance() {
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!queue.length || multiple || !isInDocument(queue[0].$el)) {
|
||||
if (!queue.length || multiple) {
|
||||
const toast = new (Vue.extend(VueToast))({
|
||||
el: document.createElement('div')
|
||||
});
|
||||
|
@@ -1,4 +1,6 @@
|
||||
import Vue from 'vue';
|
||||
import Toast from '..';
|
||||
import ToastVue from '../Toast';
|
||||
import { transitionStub, later } from '../../../test/utils';
|
||||
|
||||
transitionStub();
|
||||
@@ -86,3 +88,8 @@ test('onClose callback', () => {
|
||||
Toast.allowMultiple(false);
|
||||
expect(onClose).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('register component', () => {
|
||||
Vue.use(Toast);
|
||||
expect(Vue.component(ToastVue.name)).toBeTruthy();
|
||||
});
|
||||
|
Reference in New Issue
Block a user