-
-
Notifications
You must be signed in to change notification settings - Fork 9k
fix(runtime-core): fix rendering error when Element and Teleport children are function
#9108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Size ReportBundles
Usages
|
…children are function
61e7a78 to
e12432e
Compare
Element and Teleport children are function
baiwusanyu-c
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
cc/ @sxzz
|
Based on the comment on h.ts /*
// type only
h('div')
// type + props
h('div', {})
// type + omit props + children
// Omit props does NOT support named slots
h('div', []) // array
h('div', 'foo') // text
h('div', h('br')) // vnode
h(Component, () => {}) // default slot
// type + props + children
h('div', {}, []) // array
h('div', {}, 'foo') // text
h('div', {}, h('br')) // vnode
h(Component, {}, () => {}) // default slot
h(Component, {}, {}) // named slots
// named slots without props requires explicit `null` to avoid ambiguity
h(Component, null, {})
**/This is working as intended, this PR is requesting to change the API. The only case where we could argue otherwise would be Teleport not supporting the function. If the intention is for functions to be supported across the board |
|
@pikax let tag: string | Component = 'div'
h(tag, {}, () => 'hello world')If we only support |
I'm not saying otherwise, just saying this is a change of the current API, changing API is more cumbersome, there's typescript that needs to be updated which this PR hasn't done it, there's RFC. I would argue logically it makes sense why Element to not support functions, the reason I say that is because functions are a sugar for default slot, but Element doesn't have slots per se, is just children, because |
|
core/packages/runtime-core/src/h.ts Lines 108 to 112 in 2857a59
@pikax I see there are overloads for |
fixed #9107
When the children of the
ElementorTeleportcomponent are a function, we should execute this function and use its return value as the children.Palyground