summaryrefslogtreecommitdiff
path: root/packages/integrations/vue/client.js
diff options
context:
space:
mode:
authorGravatar Nate Moore <natemoo-re@users.noreply.github.com> 2022-05-31 11:29:36 -0500
committerGravatar GitHub <noreply@github.com> 2022-05-31 11:29:36 -0500
commite9a77d861907adccfa75811f9aaa555f186d78f8 (patch)
tree1c77ae43165a7f529ea5762811798c3873f1776c /packages/integrations/vue/client.js
parent40614597ccef567afab31621834037b0a77ed317 (diff)
downloadastro-e9a77d861907adccfa75811f9aaa555f186d78f8.tar.gz
astro-e9a77d861907adccfa75811f9aaa555f186d78f8.tar.zst
astro-e9a77d861907adccfa75811f9aaa555f186d78f8.zip
Improve nested and `client:only` hydration (#3455)
* wip: fix nested islands * fix: improve hydration for dynamic content * chore: fix bundle-size script for new files * chore: allow-list client:* directive files * fix(#3362): fix client:only behavior for React, Vue, Solid * test: add client-only e2e test * chore: update lockfile * test: fix e2e tests * test: add framework nesting e2e tests * Update packages/astro/src/runtime/client/events.ts Co-authored-by: Matthew Phillips <matthew@skypack.dev> * chore: add changeset * fix(preact): ignore hydrate roots * chore: remove `ssr` check in integrations * Revert "chore: remove `ssr` check in integrations" This reverts commit ba27eaae5514701f4b7bb6259f682fe82821a23d. * chore: add changeset Co-authored-by: Matthew Phillips <matthew@skypack.dev>
Diffstat (limited to 'packages/integrations/vue/client.js')
-rw-r--r--packages/integrations/vue/client.js15
1 files changed, 11 insertions, 4 deletions
diff --git a/packages/integrations/vue/client.js b/packages/integrations/vue/client.js
index 0ba4e8106..4832a9847 100644
--- a/packages/integrations/vue/client.js
+++ b/packages/integrations/vue/client.js
@@ -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);
+ }
};