From a78a7b6aa89db2fa775d53391bcc4a74bb9756b7 Mon Sep 17 00:00:00 2001 From: neverland Date: Fri, 21 Aug 2020 20:53:21 +0800 Subject: [PATCH 1/4] fix(Toast): failed to reopen when using get-container (#7032) --- src/toast/index.js | 6 ++++++ src/toast/test/index.spec.js | 11 ++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/toast/index.js b/src/toast/index.js index c3ec0ec12..f279bfb7c 100644 --- a/src/toast/index.js +++ b/src/toast/index.js @@ -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'), diff --git a/src/toast/test/index.spec.js b/src/toast/test/index.spec.js index 88da44408..3026877ef 100644 --- a/src/toast/test/index.spec.js +++ b/src/toast/test/index.spec.js @@ -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(); From f89f939377f90d9b4e7c826b087216d78065b1fe Mon Sep 17 00:00:00 2001 From: neverland Date: Sat, 22 Aug 2020 15:48:24 +0800 Subject: [PATCH 2/4] feat(Uploader): preview-cover slot add index param (#7036) --- src/uploader/index.js | 6 +++++- src/uploader/test/__snapshots__/index.spec.js.snap | 4 ++-- src/uploader/test/index.spec.js | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/uploader/index.js b/src/uploader/index.js index d56416cf9..909bcbcf7 100644 --- a/src/uploader/index.js +++ b/src/uploader/index.js @@ -320,7 +320,11 @@ export default createComponent({ ); - const PreviewCoverContent = this.slots('preview-cover', item); + const PreviewCoverContent = this.slots('preview-cover', { + index, + ...item, + }); + const PreviewCover = PreviewCoverContent && (
{PreviewCoverContent}
); diff --git a/src/uploader/test/__snapshots__/index.spec.js.snap b/src/uploader/test/__snapshots__/index.spec.js.snap index 172c43fc9..6421e923c 100644 --- a/src/uploader/test/__snapshots__/index.spec.js.snap +++ b/src/uploader/test/__snapshots__/index.spec.js.snap @@ -76,7 +76,7 @@ exports[`preview-cover slot 1`] = `
-
https://img.yzcdn.cn/vant/cat.jpeg
+
url: https://img.yzcdn.cn/vant/cat.jpeg, index: 0
@@ -85,7 +85,7 @@ exports[`preview-cover slot 1`] = `
-
https://img.yzcdn.cn/vant/cat.jpeg
+
url: https://img.yzcdn.cn/vant/cat.jpeg, index: 1
diff --git a/src/uploader/test/index.spec.js b/src/uploader/test/index.spec.js index 76ab58f30..d9ae2f77d 100644 --- a/src/uploader/test/index.spec.js +++ b/src/uploader/test/index.spec.js @@ -531,7 +531,7 @@ test('preview-cover slot', () => { fileList: [{ url: IMAGE }, { url: IMAGE }], }, scopedSlots: { - 'preview-cover': (item) => item.url, + 'preview-cover': (item) => `url: ${item.url}, index: ${item.index}`, }, }); From a0c10adbaeff7ea2a56627521e3a49ce4186a967 Mon Sep 17 00:00:00 2001 From: neverland Date: Sat, 22 Aug 2020 16:11:08 +0800 Subject: [PATCH 3/4] fix(Calendar): render error when using rem unit (#7037) --- src/calendar/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/calendar/index.js b/src/calendar/index.js index 7f88475c5..857f08754 100644 --- a/src/calendar/index.js +++ b/src/calendar/index.js @@ -258,8 +258,15 @@ export default createComponent({ let height = 0; let currentMonth; + // add offset to avoid rem accuracy issues + // see: https://github.com/youzan/vant/issues/6929 + const viewportOffset = 50; + const viewportTop = top - viewportOffset; + const viewportBottom = bottom + viewportOffset; + for (let i = 0; i < months.length; i++) { - const visible = height <= bottom && height + heights[i] >= top; + const visible = + height <= viewportBottom && height + heights[i] >= viewportTop; if (visible && !currentMonth) { currentMonth = months[i]; From e56615af48b15ccc9239e66b21c7ea5c345b14e1 Mon Sep 17 00:00:00 2001 From: neverland Date: Sat, 22 Aug 2020 16:56:16 +0800 Subject: [PATCH 4/4] docs: add vant next link (#7038) --- README.md | 2 ++ README.zh-CN.md | 2 ++ docs/markdown/quickstart.en-US.md | 2 ++ docs/markdown/quickstart.zh-CN.md | 2 ++ vant.config.js | 5 ++++- 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bb73583e3..09c0ecf12 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,8 @@ npm i vant -S yarn add vant ``` +> Tips: Please install Vant 3.0 for Vue 3 projects, see [issue#7035](https://github.com/youzan/vant/issues/7035) + ## Quickstart ```js diff --git a/README.zh-CN.md b/README.zh-CN.md index f39e36e19..86e8a0dcb 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -48,6 +48,8 @@ npm i vant -S yarn add vant ``` +> Tips: Vue 3 项目请安装 Vant 3.0,参见 [issue#7035](https://github.com/youzan/vant/issues/7035) + ## 快速上手 ```js diff --git a/docs/markdown/quickstart.en-US.md b/docs/markdown/quickstart.en-US.md index f86b090df..3662bf00a 100644 --- a/docs/markdown/quickstart.en-US.md +++ b/docs/markdown/quickstart.en-US.md @@ -29,6 +29,8 @@ npm i vant -S yarn add vant ``` +> Tips: Please install Vant 3.0 for Vue 3 projects, see [issue#7035](https://github.com/youzan/vant/issues/7035) + ## Usage ### 1. Import on demand diff --git a/docs/markdown/quickstart.zh-CN.md b/docs/markdown/quickstart.zh-CN.md index 3c30beef9..6eced930e 100644 --- a/docs/markdown/quickstart.zh-CN.md +++ b/docs/markdown/quickstart.zh-CN.md @@ -31,6 +31,8 @@ npm i vant -S yarn add vant ``` +> Tips: Vue 3 项目请安装 Vant 3.0,参见 [issue#7035](https://github.com/youzan/vant/issues/7035) + ### 示例工程 我们提供了一个基于 Vue Cli 的[示例工程](https://github.com/youzan/vant-demo),示例工程会帮助你了解如下内容: diff --git a/vant.config.js b/vant.config.js index d29227fec..f73352b73 100644 --- a/vant.config.js +++ b/vant.config.js @@ -11,7 +11,10 @@ module.exports = { }, site: { defaultLang: 'en-US', - versions: [{ label: '1.x', link: 'https://youzan.github.io/vant/1.x/' }], + versions: [ + { label: '1.x', link: 'https://youzan.github.io/vant/1.x/' }, + { label: '3.x', link: 'https://youzan.github.io/vant/next/' }, + ], baiduAnalytics: { seed: 'ad6b5732c36321f2dafed737ac2da92f', },