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" > - +