solid icon indicating copy to clipboard operation
solid copied to clipboard

Child textContent within label removed after hydration

Open chrstntdd opened this issue 3 years ago • 2 comments

Describe the bug

The title says it.

With standard client side rendering, rendering out a radio group with input and label's, the child textContent (a hardcoded string) is rendered as expected. When pre-rendering + hydrating, the hydration step seems to remove the child of the label.

Your Example Website or App

https://github.com/chrstntdd/solid-1.5-possible-regression

Steps to Reproduce the Bug or Issue

  1. Run the application in development (client side rendered) with pnpm dev
  2. View the application in a browser
  3. Observe the radio group is rendered correctly

  1. Build the application for production (pre-render) with pnpm build
  2. Serve the application with pnpm preview
  3. View the application in a browser
  4. Observe the labels of the radio group have content in the initial HTML
  5. Observe the labels of the radio group lack content once hydration has finished

Expected behavior

The hydration step should not remove static textContent of the label.

Screenshots or Videos

No response

Platform

  • OS: MacOS 11.6
  • Browser: All
  • Version: 1.5.X

Additional context

It's stated in the readme of the repro case, but this bug surfaced when upgrading from solid 1.4.7 to 1.5.X.

chrstntdd avatar Sep 20 '22 00:09 chrstntdd

Hmm.. all cases data-hk are being removed which suggests hydration was never working properly. Thanks for the reproduction. I will see what we can find.

ryansolid avatar Sep 20 '22 01:09 ryansolid

Looking at the example I was correct. It wasn't hydrating as it was doing a client-only compilation (both client and server builds need to be set to hydratable). Fixed it by changing your vite config to:

export default defineConfig(({ mode }) => {
  let isSSG = mode === 'ssg';

  return {
    plugins: [
      solid(
        isSSG
          ? { ssr: true, solid: { hydratable: true, generate: 'ssr' } }
          : { solid: { hydratable: true } }
      ),
    ],
    build: { manifest: !isSSG, minify: false },
    server: { port: 3000 },
  };
});

ryansolid avatar Sep 21 '22 07:09 ryansolid

All in the build tooling, wow. Thank you for your help Ryan!

chrstntdd avatar Sep 22 '22 01:09 chrstntdd