-
-
Notifications
You must be signed in to change notification settings - Fork 9k
feat(runtime-vapor): support setup fn and render fn co-usage for expose #14179
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: minor
Are you sure you want to change the base?
Changes from all commits
1385e4a
5929f33
f8be210
3e6130e
b96b8cf
30b21c6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1025,21 +1025,34 @@ function handleSetupResult( | |
| if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) { | ||
| instance.devtoolsRawSetupState = setupResult | ||
| } | ||
| instance.exposed || instance.expose(setupResult) | ||
| instance.setupState = proxyRefs(setupResult) | ||
| if (__DEV__) { | ||
| instance.setupState = createDevSetupStateProxy(instance) | ||
| } | ||
| devRender(instance) | ||
| } | ||
| } else { | ||
| // component has a render function but no setup function | ||
| // (typically components with only a template and no state) | ||
| if (setupResult === EMPTY_OBJ && component.render) { | ||
| instance.block = callWithErrorHandling( | ||
| component.render, | ||
| instance, | ||
| ErrorCodes.RENDER_FUNCTION, | ||
| ) | ||
| // component has a render function with either: | ||
| // - no setup function (components with only a template) | ||
| // - setup returning non-block state for use in render | ||
| // support setup fn and render fn co-usage for expose | ||
| if (!isBlock(setupResult) && component.render) { | ||
| instance.exposed || instance.expose(setupResult) | ||
| instance.setupState = proxyRefs(setupResult) | ||
| instance.block = | ||
| callWithErrorHandling( | ||
| component.render, | ||
| instance, | ||
| ErrorCodes.RENDER_FUNCTION, | ||
| [ | ||
| instance.setupState, | ||
| instance.props, | ||
| instance.emit, | ||
| instance.attrs, | ||
| instance.slots, | ||
| ], | ||
| ) || [] | ||
|
Comment on lines
1040
to
1055
|
||
| } else { | ||
| // in prod result can only be block | ||
| instance.block = setupResult as Block | ||
|
|
||
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.
Missing
devtoolsRawSetupStateassignment for production devtools support.The dev-only path at lines 965-966 sets
instance.devtoolsRawSetupStatewhen__DEV__ || __FEATURE_PROD_DEVTOOLS__is true. This production code path should have the same assignment to ensure devtools work correctly in production builds with devtools enabled.Suggestion: Add before line 979: