mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
Revert "fix(components): [table] render default slot only when it returns valid vnodes (#21651)" (#21728)
* revert: revert fix table slot rendering (#21651)
* Revert "fix(components): [table] render default slot only when it returns valid vnodes (#21651)"
This reverts commit 6bf6313f35.
---------
Co-authored-by: dopamine <coderzyou@gmail.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
Comment,
|
||||
computed,
|
||||
getCurrentInstance,
|
||||
h,
|
||||
@@ -7,12 +8,7 @@ import {
|
||||
unref,
|
||||
watchEffect,
|
||||
} from 'vue'
|
||||
import {
|
||||
debugWarn,
|
||||
ensureValidVNode,
|
||||
isArray,
|
||||
isUndefined,
|
||||
} from '@element-plus/utils'
|
||||
import { debugWarn, isArray, isUndefined } from '@element-plus/utils'
|
||||
import { useNamespace } from '@element-plus/hooks'
|
||||
import {
|
||||
cellForced,
|
||||
@@ -164,7 +160,9 @@ function useRender<T extends DefaultRow>(
|
||||
let children: VNode | VNode[] | null = null
|
||||
if (slots.default) {
|
||||
const vnodes = slots.default(data)
|
||||
children = ensureValidVNode(vnodes) ? vnodes : originRenderCell(data)
|
||||
children = vnodes.some((v) => v.type !== Comment)
|
||||
? vnodes
|
||||
: originRenderCell(data)
|
||||
} else {
|
||||
children = originRenderCell(data)
|
||||
}
|
||||
|
||||
@@ -170,21 +170,3 @@ export const flattedChildren = (
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
// Copyied from https://github.com/vuejs/core/blob/c875019d49b4c36a88d929ccadc31ad414747c7b/packages/runtime-core/src/helpers/renderSlot.ts#L102
|
||||
export function ensureValidVNode(
|
||||
vnodes: VNodeArrayChildren
|
||||
): VNodeArrayChildren | null {
|
||||
return vnodes.some((child) => {
|
||||
if (!isVNode(child)) return true
|
||||
if (child.type === Comment) return false
|
||||
if (
|
||||
child.type === Fragment &&
|
||||
!ensureValidVNode(child.children as VNodeArrayChildren)
|
||||
)
|
||||
return false
|
||||
return true
|
||||
})
|
||||
? vnodes
|
||||
: null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user