Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If {someValue} in <Title>{someValue}</Title> evaluates to a falsified value, <title sm="..." /> is rendered which is invalid #26

Open
krymel opened this issue Jan 19, 2023 · 0 comments

Comments

@krymel
Copy link

krymel commented Jan 19, 2023

Hi,

Initially, I did this in my codebase:

<Title>{errorReport().code || ''}</Title>

because of https://github.com/solidjs/solid-meta/blob/main/src/index.tsx#L222 [falsification trenary operation], empty string as well as undefined leads to a rendering of <title sm="..." /> which the browser autocorrects and breaks hydration and rendering of all succeeding elements (at least in Chrome).

I tried to fix it by simply doing a quick hack for the moment:

<Title>{errorReport().code || ' '}</Title>

which leads to a rendering of two TextNodes, one that contains the {errorReport().code} and another one that is the space.

Only providing actual content as an alternative like:

<Title>{errorReport().code || 'Loading...'}</Title>

Leads to a correct rendering.

The issue only happens when you do server-side rendering combined with multiple client-side renders where the first iteration clears to empty/falsified value for the CDATA followed by a single TextNode as CDATA.

I'd suggest the following fix:
return tag.props.children || tag.tag === 'title'

which leads to a correct rendering. Closing <title> without an actual closing tag can never be valid.

Thanks and best

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

No branches or pull requests

1 participant