-
Notifications
You must be signed in to change notification settings - Fork 407
Description
Duplicates
- I have searched the existing issues
Latest version
- I have tested the latest version
Current behavior π―
Setting a data attribute to false || undefined will lead to "false" in the SSR output.
import { createSignal } from "solid-js";
export default function App() {
const [falseSignal1] = createSignal(false)
return (
<main
data-false={false || undefined} // "false"
data-reverse={undefined || false} // "false"
data-signal={falseSignal1() || undefined} // "false"
bool:data-bool={false || undefined} // "false"
data-undefined={undefined} // nothing
data-string={"" || undefined} // nothing
data-null={null || undefined} // nothing
>
why
</main>
);
}Hardcoded false || undefined always seems to appear as "false", but it can be flaky sometimes, maybe HMR or client side navigation instead of SSR work properly.
I have tested in dev and after build, cleared .vinxi cache, tested in bare template and old codebase, updated dependencies to latest.
EDIT:
Something in dom-expressions is changing it to escape(false, true) || escape(undefined, true) which becomes "false" || undefined
Expected behavior π€
The data attribute should be removed.
Steps to reproduce πΉ
Steps:
- Create new bare solidstart app (
pnpm create solid) - Add
data-test={false || undefined}to any element - Inspect element
- See
data-test="false"
Context π¦
I am using data attributes to apply dynamic tailwind styles. By writing data-[something] to match existence instead of data-[something=true] I type less characters. Removing attribute by setting undefined is common practice, see kobalte code https://github.com/search?q=repo%3Akobaltedev%2Fkobalte%20%7C%7C%20undefined&type=code
Your environment π
"dependencies": {
"@solidjs/start": "^1.2.1",
"solid-js": "^1.9.11",
"vinxi": "^0.5.11"
},