-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(#3362): fix client:only behavior for React, Vue, Solid
- Loading branch information
Nate Moore
committed
May 26, 2022
1 parent
362ab17
commit d58e8cc
Showing
4 changed files
with
28 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
import { h, createSSRApp } from 'vue'; | ||
import { h, createSSRApp, createApp } from 'vue'; | ||
import StaticHtml from './static-html.js'; | ||
|
||
export default (element) => (Component, props, children) => { | ||
export default (element) => (Component, props, children, { client }) => { | ||
delete props['class']; | ||
if (!element.hasAttribute('ssr')) return; | ||
|
||
// Expose name on host component for Vue devtools | ||
const name = Component.name ? `${Component.name} Host` : undefined; | ||
const slots = {}; | ||
if (children != null) { | ||
slots.default = () => h(StaticHtml, { value: children }); | ||
} | ||
const app = createSSRApp({ name, render: () => h(Component, props, slots) }); | ||
app.mount(element, true); | ||
if (client === 'only') { | ||
const app = createApp({ name, render: () => h(Component, props, slots) }); | ||
app.mount(element, false); | ||
} else { | ||
const app = createSSRApp({ name, render: () => h(Component, props, slots) }); | ||
app.mount(element, true); | ||
} | ||
}; |