mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(Toast): failed to reopen when using get-container (#7032)
This commit is contained in:
parent
60ce7e048e
commit
a78a7b6aa8
@ -43,12 +43,18 @@ function parseOptions(message) {
|
||||
return { message };
|
||||
}
|
||||
|
||||
function isInDocument(element) {
|
||||
return document.body.contains(element);
|
||||
}
|
||||
|
||||
function createInstance() {
|
||||
/* istanbul ignore if */
|
||||
if (isServer) {
|
||||
return {};
|
||||
}
|
||||
|
||||
queue = queue.filter((item) => isInDocument(item.$el));
|
||||
|
||||
if (!queue.length || multiple) {
|
||||
const toast = new (Vue.extend(VueToast))({
|
||||
el: document.createElement('div'),
|
||||
|
@ -74,26 +74,31 @@ test('icon-prefix prop', async () => {
|
||||
expect(toast.$el.outerHTML).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('clear toast', () => {
|
||||
const toast1 = Toast();
|
||||
test('clear toast', async () => {
|
||||
const toast1 = Toast('1');
|
||||
await later();
|
||||
expect(toast1.value).toBeTruthy();
|
||||
Toast.clear();
|
||||
expect(toast1.value).toBeFalsy();
|
||||
|
||||
Toast.allowMultiple();
|
||||
const toast2 = Toast('2');
|
||||
await later();
|
||||
const toast3 = Toast('3');
|
||||
await later();
|
||||
Toast.clear(true);
|
||||
expect(toast2.value).toBeFalsy();
|
||||
expect(toast3.value).toBeFalsy();
|
||||
Toast.allowMultiple(false);
|
||||
});
|
||||
|
||||
test('clear multiple toast', () => {
|
||||
test('clear multiple toast', async () => {
|
||||
Toast.allowMultiple();
|
||||
Toast.clear(true);
|
||||
const toast1 = Toast.success('1');
|
||||
await later();
|
||||
const toast2 = Toast.success('2');
|
||||
await later();
|
||||
Toast.clear();
|
||||
expect(toast1.value).toBeFalsy();
|
||||
expect(toast2.value).toBeTruthy();
|
||||
|
Loading…
x
Reference in New Issue
Block a user