Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ssrElement emits style="" / class="" for nullish values #3382

Description

@ryansolid

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions