fuc-new/doc/node_modules/@vuepress/helper/lib/client/utils/isSlotContentEmpty.js
hellcat 6adbc04d4b 1
2025-10-03 17:17:08 +08:00

29 lines
1.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { Comment, Fragment } from 'vue';
import { isArray } from '../../shared/index.js';
const isVNodeChildrenEmpty = (children) => children.every((item) => {
if (item.type === Comment)
return true;
if (item.type === Fragment) {
return (item.children == null ||
(isArray(item.children) &&
isVNodeChildrenEmpty(item.children)));
}
return false;
});
/**
* Check whether a slot is currently empty.
*
* 检查插槽当前是否为空
*
* @param normalizedSlotContent - The normalized slot content, which should be the results of the slot function / 标准化的插槽内容,应该是插槽函数的结果
*
* @returns True if the slot content is empty, false otherwise / 如果插槽内容为空则返回 true否则返回 false
*/
export const isSlotContentEmpty = (normalizedSlotContent) => {
if (normalizedSlotContent == null)
return true;
if (isArray(normalizedSlotContent))
return isVNodeChildrenEmpty(normalizedSlotContent);
return false;
};