fix(date-picker): when default slot is a comment node, date-picker will not display (#4105)
parent
5b36b9c43e
commit
f437e9124d
|
@ -341,6 +341,10 @@ export function isEmptyElement(c) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isEmptySlot(c) {
|
||||||
|
return !c || c().every(isEmptyElement);
|
||||||
|
}
|
||||||
|
|
||||||
export function isStringElement(c) {
|
export function isStringElement(c) {
|
||||||
return c && c.type === Text;
|
return c && c.type === Text;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import { hasProp, getOptionProps, getComponent, isValidElement } from '../_util/
|
||||||
import { cloneElement } from '../_util/vnode';
|
import { cloneElement } from '../_util/vnode';
|
||||||
import { formatDate } from './utils';
|
import { formatDate } from './utils';
|
||||||
import { getDataAndAriaProps } from '../_util/util';
|
import { getDataAndAriaProps } from '../_util/util';
|
||||||
|
import { isEmptySlot } from '../_util/props-util';
|
||||||
|
|
||||||
export interface PickerProps {
|
export interface PickerProps {
|
||||||
value?: moment.Moment;
|
value?: moment.Moment;
|
||||||
|
@ -255,7 +256,7 @@ export default function createPicker<P>(
|
||||||
>
|
>
|
||||||
<VcDatePicker
|
<VcDatePicker
|
||||||
{...vcDatePickerProps}
|
{...vcDatePickerProps}
|
||||||
v-slots={{ default: input, ...$slots }}
|
v-slots={{ ...$slots, default: isEmptySlot($slots.default) ? input : $slots.default }}
|
||||||
></VcDatePicker>
|
></VcDatePicker>
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue