2024-01-29 09:26:07 +08:00

12 lines
328 B
JavaScript

export function getVNodeChildren(vNode, slotName = 'default', fallback = []) {
const {
children
} = vNode;
if (children !== null && typeof children === 'object' && !Array.isArray(children)) {
const slot = children[slotName];
if (typeof slot === 'function') {
return slot();
}
}
return fallback;
}