summaryrefslogtreecommitdiff
path: root/packages/astro/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/astro/src')
-rw-r--r--packages/astro/src/compiler/codegen/index.ts8
1 files changed, 5 insertions, 3 deletions
diff --git a/packages/astro/src/compiler/codegen/index.ts b/packages/astro/src/compiler/codegen/index.ts
index 05a45c35b..b8d6c1f76 100644
--- a/packages/astro/src/compiler/codegen/index.ts
+++ b/packages/astro/src/compiler/codegen/index.ts
@@ -30,6 +30,8 @@ const traverse: typeof babelTraverse.default = (babelTraverse.default as any).de
const babelGenerator: typeof _babelGenerator = _babelGenerator.default;
const { transformSync } = esbuild;
+const hydrationDirectives = new Set(['client:load', 'client:idle', 'client:visible', 'client:media']);
+
interface Attribute {
start: number;
end: number;
@@ -55,8 +57,6 @@ function findHydrationAttributes(attrs: Record<string, string>): HydrationAttrib
let method: HydrationAttributes['method'];
let value: undefined | string;
- const hydrationDirectives = new Set(['client:load', 'client:idle', 'client:visible', 'client:media']);
-
for (const [key, val] of Object.entries(attrs)) {
if (hydrationDirectives.has(key)) {
method = key.slice(7) as HydrationAttributes['method'];
@@ -155,7 +155,9 @@ function getTextFromAttribute(attr: any): string {
function generateAttributes(attrs: Record<string, string>): string {
let result = '{';
for (const [key, val] of Object.entries(attrs)) {
- if (key.startsWith('...')) {
+ if (hydrationDirectives.has(key)) {
+ continue;
+ } else if (key.startsWith('...')) {
result += key + ',';
} else {
result += JSON.stringify(key) + ':' + val + ',';