From af8401ebf9e5cbe94ded0d0f745ed1e3ec6f6d8a Mon Sep 17 00:00:00 2001 From: sammibajrami Date: Sat, 5 Oct 2024 13:48:30 +0200 Subject: [PATCH] Fixed an "Uncaught ReferenceError" inside of the @astrojs/vue package (#12116) * fix(vue): initialized the 'app' variable earlier in the client.js script by assigning the 'appInstance' reference to it so that it is available for the later established 'astro:unmount' event listener * Add changeset * fix(vue): reverted the last change and instead moved the 'astro:unmount' event listener to inside of the 'if' statement where the 'app' variable is initialized --------- Co-authored-by: Matt Kane --- .changeset/wicked-sloths-cry.md | 5 +++++ packages/integrations/vue/client.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/wicked-sloths-cry.md diff --git a/.changeset/wicked-sloths-cry.md b/.changeset/wicked-sloths-cry.md new file mode 100644 index 000000000000..e701bb6b860d --- /dev/null +++ b/.changeset/wicked-sloths-cry.md @@ -0,0 +1,5 @@ +--- +"@astrojs/vue": patch +--- + +Fixes an Reference Error that occurred during client transitions diff --git a/packages/integrations/vue/client.js b/packages/integrations/vue/client.js index b3935752c08c..4ec2b9e6843b 100644 --- a/packages/integrations/vue/client.js +++ b/packages/integrations/vue/client.js @@ -44,12 +44,12 @@ export default (element) => await setup(app); app.mount(element, isHydrate); appMap.set(element, appInstance); + element.addEventListener('astro:unmount', () => app.unmount(), { once: true }); } else { appInstance.props = props; appInstance.slots = slots; appInstance.component.$forceUpdate(); } - element.addEventListener('astro:unmount', () => app.unmount(), { once: true }); }; function isAsync(fn) {