Skip to content

Commit b43f4f5

Browse files
committed
Merge branch 'setup-hmr' into jsx-vapor
2 parents 3e7464f + f264ceb commit b43f4f5

File tree

1 file changed

+35
-20
lines changed

1 file changed

+35
-20
lines changed

Diff for: packages/runtime-vapor/src/component.ts

+35-20
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,14 @@ export function createComponent(
182182
appContext,
183183
)
184184

185+
// HMR
186+
if (__DEV__ && component.__hmrId) {
187+
registerHMR(instance)
188+
instance.isSingleRoot = isSingleRoot
189+
instance.hmrRerender = hmrRerender.bind(null, instance)
190+
instance.hmrReload = hmrReload.bind(null, instance)
191+
}
192+
185193
if (__DEV__) {
186194
pushWarningContext(instance)
187195
startMeasure(instance, `init`)
@@ -221,14 +229,6 @@ export function createComponent(
221229
// TODO make the proxy warn non-existent property access during dev
222230
instance.setupState = proxyRefs(setupResult)
223231
devRender(instance)
224-
225-
// HMR
226-
if (component.__hmrId) {
227-
registerHMR(instance)
228-
instance.isSingleRoot = isSingleRoot
229-
instance.hmrRerender = hmrRerender.bind(null, instance)
230-
instance.hmrReload = hmrReload.bind(null, instance)
231-
}
232232
}
233233
} else {
234234
// component has a render function but no setup function
@@ -283,18 +283,33 @@ export let isApplyingFallthroughProps = false
283283
*/
284284
export function devRender(instance: VaporComponentInstance): void {
285285
instance.block =
286-
callWithErrorHandling(
287-
instance.type.render!,
288-
instance,
289-
ErrorCodes.RENDER_FUNCTION,
290-
[
291-
instance.setupState,
292-
instance.props,
293-
instance.emit,
294-
instance.attrs,
295-
instance.slots,
296-
],
297-
) || []
286+
(instance.type.render
287+
? callWithErrorHandling(
288+
instance.type.render,
289+
instance,
290+
ErrorCodes.RENDER_FUNCTION,
291+
[
292+
instance.setupState,
293+
instance.props,
294+
instance.emit,
295+
instance.attrs,
296+
instance.slots,
297+
],
298+
)
299+
: callWithErrorHandling(
300+
isFunction(instance.type) ? instance.type : instance.type.setup!,
301+
instance,
302+
ErrorCodes.SETUP_FUNCTION,
303+
[
304+
instance.props,
305+
{
306+
slots: instance.slots,
307+
attrs: instance.attrs,
308+
emit: instance.emit,
309+
expose: instance.expose,
310+
},
311+
],
312+
)) || []
298313
}
299314

300315
const emptyContext: GenericAppContext = {

0 commit comments

Comments
 (0)