From 20951cfa7b06ce18d31f83eadce57204afa7a465 Mon Sep 17 00:00:00 2001 From: meteor Date: Thu, 20 May 2021 20:15:51 +0800 Subject: [PATCH] fix(date-picker): when default slot is a comment node, date-picker will not display --- components/_util/props-util/index.js | 4 ++++ components/date-picker/createPicker.tsx | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/components/_util/props-util/index.js b/components/_util/props-util/index.js index 86eb35642c..1004d47f8e 100644 --- a/components/_util/props-util/index.js +++ b/components/_util/props-util/index.js @@ -341,6 +341,10 @@ export function isEmptyElement(c) { ); } +export function isEmptySlot(c) { + return !c || c().every(isEmptyElement); +} + export function isStringElement(c) { return c && c.type === Text; } diff --git a/components/date-picker/createPicker.tsx b/components/date-picker/createPicker.tsx index 0a31752236..3d317416e4 100644 --- a/components/date-picker/createPicker.tsx +++ b/components/date-picker/createPicker.tsx @@ -14,6 +14,7 @@ import { hasProp, getOptionProps, getComponent, isValidElement } from '../_util/ import { cloneElement } from '../_util/vnode'; import { formatDate } from './utils'; import { getDataAndAriaProps } from '../_util/util'; +import { isEmptySlot } from '../_util/props-util'; export interface PickerProps { value?: moment.Moment; @@ -255,7 +256,7 @@ export default function createPicker

( > );