From 52448c3db87319010742a932544627517a74dd32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=98=89=E6=B6=B5?= Date: Thu, 6 Jun 2019 11:19:19 +0800 Subject: [PATCH] [bugfix] Toast: redundant instance when sync called multil times --- packages/toast/index.js | 4 ++-- packages/toast/test/index.spec.js | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/toast/index.js b/packages/toast/index.js index debdd299f..8f4f5c03d 100644 --- a/packages/toast/index.js +++ b/packages/toast/index.js @@ -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', @@ -28,7 +28,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') }); diff --git a/packages/toast/test/index.spec.js b/packages/toast/test/index.spec.js index d2bc734c1..45aaeb25e 100644 --- a/packages/toast/test/index.spec.js +++ b/packages/toast/test/index.spec.js @@ -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(); +});