Version: 2.0.0-rc.8 (@solidjs/web)
Repro
import { ssrElement } from "@solidjs/web";
ssrElement("button", { style: undefined, class: undefined, id: undefined }, undefined, true);
// { t: '<button style="" class="" ></button>' } ← id is skipped, style/class are not
Same thing from compiled JSX with a spread whose style/class resolve to undefined, and from any component that forwards a class getter that may return nothing (this is how @yak/solid 0.1.0 ships style="" on every styled(Component) element).
Cause
packages/web/src/server.ts ssrElement (~3609): the prop === "style" and prop === "class" branches run before the value == undefined check, so ssrStyle(undefined) / ssrClassName(undefined) are written as empty attributes. Every other attribute is skipped when nullish.
Expected
Nullish style/class are omitted, matching every other attribute and matching the client (className(node, undefined) removes the attribute). Also mirrors what the compiler emits for a static class={undefined}.
Notes
Version: 2.0.0-rc.8 (
@solidjs/web)Repro
Same thing from compiled JSX with a spread whose
style/classresolve toundefined, and from any component that forwards aclassgetter that may return nothing (this is how@yak/solid0.1.0 shipsstyle=""on everystyled(Component)element).Cause
packages/web/src/server.tsssrElement(~3609): theprop === "style"andprop === "class"branches run before thevalue == undefinedcheck, sossrStyle(undefined)/ssrClassName(undefined)are written as empty attributes. Every other attribute is skipped when nullish.Expected
Nullish
style/classare omitted, matching every other attribute and matching the client (className(node, undefined)removes the attribute). Also mirrors what the compiler emits for a staticclass={undefined}.Notes
>when the last prop is skipped (<li _hk=0 >) — cosmetic, same code path, worth cleaning while there.@yak/solidaudit (DigitecGalaxus/next-yak#644); base vs PR HTML in ryansolid/yak-bench differs by exactly this attribute plus Why ES6 Proxies? #2.