Duplicates
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"
},
Duplicates
Latest version
Current behavior 😯
Setting a data attribute to
false || undefinedwill lead to"false"in the SSR output.Hardcoded
false || undefinedalways 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
.vinxicache, tested in bare template and old codebase, updated dependencies to latest.EDIT:
Something in
dom-expressionsis changing it toescape(false, true) || escape(undefined, true)which becomes"false" || undefinedExpected behavior 🤔
The data attribute should be removed.
Steps to reproduce 🕹
Steps:
pnpm create solid)data-test={false || undefined}to any elementdata-test="false"Context 🔦
I am using data attributes to apply dynamic tailwind styles. By writing
data-[something]to match existence instead ofdata-[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=codeYour environment 🌎