From 03e8b750ada926cca53d755947fc422e77285fb9 Mon Sep 17 00:00:00 2001 From: Rishi Raj Jain Date: Mon, 26 Sep 2022 22:23:07 +0530 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20BUG:=20class:list=20direc?= =?UTF-8?q?tive=20adding=20class=20attribute=20when=20undefined=20(#4867)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update hydration.ts * Create lucky-comics-bow.md --- .changeset/lucky-comics-bow.md | 5 +++++ packages/astro/src/runtime/server/hydration.ts | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .changeset/lucky-comics-bow.md diff --git a/.changeset/lucky-comics-bow.md b/.changeset/lucky-comics-bow.md new file mode 100644 index 000000000..92af2ec29 --- /dev/null +++ b/.changeset/lucky-comics-bow.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +check if class:list's value is defined before converting diff --git a/packages/astro/src/runtime/server/hydration.ts b/packages/astro/src/runtime/server/hydration.ts index 436e19f3c..cb26b72e8 100644 --- a/packages/astro/src/runtime/server/hydration.ts +++ b/packages/astro/src/runtime/server/hydration.ts @@ -92,8 +92,10 @@ export function extractDirectives(inputProps: Record): Ext } } } else if (key === 'class:list') { - // support "class" from an expression passed into a component (#782) - extracted.props[key.slice(0, -5)] = serializeListValue(value); + if (value) { + // support "class" from an expression passed into a component (#782) + extracted.props[key.slice(0, -5)] = serializeListValue(value); + } } else { extracted.props[key] = value; }