16 lines
480 B
JavaScript
Raw Normal View History

2024-01-29 09:26:07 +08:00
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
2024-08-02 18:19:39 +08:00
exports.getVNodeChildren = getVNodeChildren;
2024-01-29 09:26:07 +08:00
function getVNodeChildren(vNode, slotName = 'default', fallback = []) {
const { children } = vNode;
2024-08-02 18:19:39 +08:00
if (children !== null
&& typeof children === 'object'
&& !Array.isArray(children)) {
2024-01-29 09:26:07 +08:00
const slot = children[slotName];
if (typeof slot === 'function') {
return slot();
}
}
return fallback;
}