fix(date-picker): when default slot is a comment node, date-picker will not display (#4105)

pull/4111/head
meteor 2021-05-23 20:24:41 +08:00 committed by GitHub
parent 5b36b9c43e
commit f437e9124d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -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;
}

View File

@ -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<P>(
>
<VcDatePicker
{...vcDatePickerProps}
v-slots={{ default: input, ...$slots }}
v-slots={{ ...$slots, default: isEmptySlot($slots.default) ? input : $slots.default }}
></VcDatePicker>
</span>
);