From c1abd0052f728b53293579e92b619b5f8c887781 Mon Sep 17 00:00:00 2001 From: yangjinfeng Date: Fri, 9 Dec 2022 18:26:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4tab=20wrap-class?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E5=8F=8Acascader=20review=E7=BB=86=E8=8A=82?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/cascader/demo/index.ts | 25 +++++++++++++++++- packages/cascader/index.less | 4 --- packages/cascader/index.wxml | 2 +- packages/common/utils.ts | 26 +------------------ .../test/__snapshots__/demo.spec.ts.snap | 2 +- .../icon/test/__snapshots__/demo.spec.ts.snap | 2 +- .../test/__snapshots__/demo.spec.ts.snap | 2 +- packages/tab/README.md | 1 + .../tab/test/__snapshots__/demo.spec.ts.snap | 20 +++++++------- packages/tabs/index.wxml | 2 +- 10 files changed, 41 insertions(+), 45 deletions(-) diff --git a/packages/cascader/demo/index.ts b/packages/cascader/demo/index.ts index f82cfe2b..409ba2f7 100644 --- a/packages/cascader/demo/index.ts +++ b/packages/cascader/demo/index.ts @@ -1,5 +1,28 @@ import { VantComponent } from '../../common/component'; -import { deepClone } from '../../common/utils'; +import { isDef } from '../../common/utils'; +import { isObj } from '../../common/validator'; + +function deepClone>(obj: T): T { + if (!isDef(obj)) { + return obj; + } + + if (Array.isArray(obj)) { + return obj.map((item) => deepClone(item)) as unknown as T; + } + + if (isObj(obj)) { + const to = {} as Record; + Object.keys(obj).forEach((key: string) => { + // @ts-ignore + to[key] = deepClone(obj[key]); + }); + + return to as T; + } + + return obj; +} const zhCNOptions = [ { diff --git a/packages/cascader/index.less b/packages/cascader/index.less index eeabef83..056358f2 100644 --- a/packages/cascader/index.less +++ b/packages/cascader/index.less @@ -68,10 +68,6 @@ } } - &__selected-icon { - font-size: @cascader-selected-icon-size !important; - } - &__options { box-sizing: border-box; height: @cascader-options-height; diff --git a/packages/cascader/index.wxml b/packages/cascader/index.wxml index 45c1c42d..b1d724b9 100644 --- a/packages/cascader/index.wxml +++ b/packages/cascader/index.wxml @@ -44,7 +44,7 @@ bind:tap="onSelect" > {{ option[textKey] }} - + diff --git a/packages/common/utils.ts b/packages/common/utils.ts index 57d84dab..8904a0ec 100644 --- a/packages/common/utils.ts +++ b/packages/common/utils.ts @@ -1,4 +1,4 @@ -import { isDef, isNumber, isPlainObject, isPromise, isObj } from './validator'; +import { isDef, isNumber, isPlainObject, isPromise } from './validator'; import { canIUseGroupSetData, canIUseNextTick, @@ -116,27 +116,3 @@ export function getCurrentPage() { const pages = getCurrentPages(); return pages[pages.length - 1] as T & WechatMiniprogram.Page.TrivialInstance; } - -export function deepClone | null | undefined>( - obj: T -): T { - if (!isDef(obj)) { - return obj; - } - - if (Array.isArray(obj)) { - return obj.map((item) => deepClone(item)) as unknown as T; - } - - if (isObj(obj)) { - const to = {} as Record; - Object.keys(obj).forEach((key: string) => { - // @ts-ignore - to[key] = deepClone(obj[key]); - }); - - return to as T; - } - - return obj; -} diff --git a/packages/empty/test/__snapshots__/demo.spec.ts.snap b/packages/empty/test/__snapshots__/demo.spec.ts.snap index 077923f1..0cc8524e 100644 --- a/packages/empty/test/__snapshots__/demo.spec.ts.snap +++ b/packages/empty/test/__snapshots__/demo.spec.ts.snap @@ -70,7 +70,7 @@ exports[`should render demo and match snapshot 1`] = ` style="z-index:1" > - +