diff --git a/packages/svelte2tsx/src/htmlxtojsx_v2/index.ts b/packages/svelte2tsx/src/htmlxtojsx_v2/index.ts
index 0b6647b3a..49474ca2a 100644
--- a/packages/svelte2tsx/src/htmlxtojsx_v2/index.ts
+++ b/packages/svelte2tsx/src/htmlxtojsx_v2/index.ts
@@ -91,7 +91,7 @@ export function convertHtmlxToJsx(
? element
: undefined
);
- if (!element) {
+ if (parent === ast) {
// root snippet -> move to instance script
rootSnippets.push([node.start, node.end]);
}