fix: 🐛 BUG: class:list directive adding class attribute when undefined (#4867)

* Update hydration.ts

* Create lucky-comics-bow.md
This commit is contained in:
Rishi Raj Jain 2022-09-26 22:23:07 +05:30 committed by GitHub
parent 5fc73ba02c
commit 03e8b750ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
check if class:list's value is defined before converting

View file

@ -92,8 +92,10 @@ export function extractDirectives(inputProps: Record<string | number, any>): 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;
}