Describe the bug
A ref that writes an attribute keeps its value after hydration but loses it on client creation. For a value it can't inline, the compiler emits setAttribute after ref, and setAttribute is skipped while hydrating.
import { SIGN_OUT } from "./config";
export const SignOut = () => (
<a href={SIGN_OUT} ref={el => { el.href = `${SIGN_OUT}?app=${location.origin}`; }}>Sign out</a>
);
@solidjs/compiler 2.0.0-rc.10, generate: "dom":
_$ref(() => { return (el) => { el.href = `${SIGN_OUT}?app=${location.origin}`; }; }, _el$);
_$claimElement(_el$);
_$setAttribute(_el$, "href", SIGN_OUT);
If SIGN_OUT is a literal in the same module, it is folded into the template and the ref wins in both paths.
Your Example Website or App
Minimal component above.
Steps to Reproduce the Bug or Issue
- SSR and hydrate a page with
<SignOut />: href has ?app=….
- Render
<SignOut /> on the client, for example after a router navigation: href is the bare SIGN_OUT.
Expected behavior
The same result in both paths, for example with refs running after the element's attributes are applied.
Platform
- OS: macOS
- Browser: Chrome
- Version: solid-js, @solidjs/web and @solidjs/compiler 2.0.0-rc.10
Describe the bug
A ref that writes an attribute keeps its value after hydration but loses it on client creation. For a value it can't inline, the compiler emits
setAttributeafterref, andsetAttributeis skipped while hydrating.@solidjs/compiler2.0.0-rc.10,generate: "dom":If
SIGN_OUTis a literal in the same module, it is folded into the template and the ref wins in both paths.Your Example Website or App
Minimal component above.
Steps to Reproduce the Bug or Issue
<SignOut />:hrefhas?app=….<SignOut />on the client, for example after a router navigation:hrefis the bareSIGN_OUT.Expected behavior
The same result in both paths, for example with refs running after the element's attributes are applied.
Platform