Skip to content

Commit f437e91

Browse files
authored
fix(date-picker): when default slot is a comment node, date-picker will not display (#4105)
1 parent 5b36b9c commit f437e91

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

components/_util/props-util/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,10 @@ export function isEmptyElement(c) {
341341
);
342342
}
343343

344+
export function isEmptySlot(c) {
345+
return !c || c().every(isEmptyElement);
346+
}
347+
344348
export function isStringElement(c) {
345349
return c && c.type === Text;
346350
}

components/date-picker/createPicker.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { hasProp, getOptionProps, getComponent, isValidElement } from '../_util/
1414
import { cloneElement } from '../_util/vnode';
1515
import { formatDate } from './utils';
1616
import { getDataAndAriaProps } from '../_util/util';
17+
import { isEmptySlot } from '../_util/props-util';
1718

1819
export interface PickerProps {
1920
value?: moment.Moment;
@@ -255,7 +256,7 @@ export default function createPicker<P>(
255256
>
256257
<VcDatePicker
257258
{...vcDatePickerProps}
258-
v-slots={{ default: input, ...$slots }}
259+
v-slots={{ ...$slots, default: isEmptySlot($slots.default) ? input : $slots.default }}
259260
></VcDatePicker>
260261
</span>
261262
);

0 commit comments

Comments
 (0)