Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
revert state name
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Aug 2, 2022
1 parent 3ff8bbb commit 4d400c7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/nuxt/src/app/components/client-only.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,29 @@ export function createClientOnly (component) {
if (_render) {
// override the component render (non <script setup> component)
component.render = (ctx, ...args) => {
return ctx.__mounted__
return ctx.mounted$
? h(Fragment, null, [h(_render(ctx, ...args), ctx.$attrs ?? ctx._.attrs)])
: h('div', ctx.$attrs ?? ctx._.attrs)
}
} else if (_template) {
// handle runtime-compiler template
component.template = `
<template v-if="__mounted__">${_template}</template>
<template v-if="mounted$">${_template}</template>
<template v-else><div></div></template>
`
}
return defineComponent({
...component,
setup (props, ctx) {
const __mounted__ = ref(false)
onMounted(() => { __mounted__.value = true })
const mounted$ = ref(false)
onMounted(() => { mounted$.value = true })

return Promise.resolve(setup?.(props, ctx) || {})
.then((setupState) => {
return typeof setupState !== 'function'
? { ...setupState, __mounted__ }
? { ...setupState, mounted$ }
: () => {
return __mounted__.value
return mounted$.value
// use Fragment to avoid oldChildren is null issue
? h(Fragment, null, [h(setupState(props, ctx), ctx.attrs)])
: h('div', ctx.attrs)
Expand Down

0 comments on commit 4d400c7

Please sign in to comment.