Skip to content

Fix css ssr generation bug - #22

Open
FoxMoss wants to merge 1 commit into
rewritefrom
fox-fix-ssr-css
Open

Fix css ssr generation bug#22
FoxMoss wants to merge 1 commit into
rewritefrom
fox-fix-ssr-css

Conversation

@FoxMoss

@FoxMoss FoxMoss commented May 24, 2026

Copy link
Copy Markdown
Member

This PR patches bugged behavior in situations like the following:

2026-05-22.17-34-11.mp4
import { css, type FC, type ComponentChild  } from "dreamland/core";

export function PageTemplate(this: FC<{ children?: ComponentChild }, {}>) {
  return (
    <div>
      <div class="container">
        <div class="paragraph">
          <h1 class="title lato-black">Palatine Hill</h1>
          <div class="border" />
        </div>
        <h3 class="lato-bold paragraph">{this.children}</h3>
      </div>
    </div>
  );
}

PageTemplate.style = css`
  .title {
    width: 300px;
    margin-bottom: 0;
    font-size: xxx-large;
  }

  .container {
    margin-top: 40px;

    color: #5c4e43;
  }
  @media screen and (width >= 800px) {
    .container {
      margin-left: calc((100vw - 70vw) / 2);
      margin-right: calc((100vw - 70vw) / 2);
    }
  }

  @media screen and (width < 800px) {
    .paragraph {
      margin: 10px;
    }
  }
  .border {
    position: absolute;
    width: 260px;
    border: 2px solid #5c4e43;
    filter: url(#squiggle);
  }
`;

export function Page404(this: FC<{}, {}>) {
  return (
    <PageTemplate>
      404, Hill not found.
    </PageTemplate>
  );
}

With this PR the bug is patched.

As I understand it the issues was with the SSR vdom not properly including the css id for all components. This traces back to an issue in src/core/jsx/index.ts where the element $ was set multiple times and on occasion with undefined values.

No idea where these undefined values come from.

Full disclosure here's the LLM outputs that I used: https://claude.ai/share/72dd5ce3-fdab-43e0-adff-4c6102d17d1c

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant