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

<ToolTip/> throws HTMLElement is not defined #414

Closed
lovasoa opened this issue Jan 4, 2022 · 9 comments · Fixed by #421
Closed

<ToolTip/> throws HTMLElement is not defined #414

lovasoa opened this issue Jan 4, 2022 · 9 comments · Fixed by #421

Comments

@lovasoa
Copy link
Contributor

lovasoa commented Jan 4, 2022

Hello,
It looks like since the latest update the <ToolTip/> element is broken and throws HTMLElement is not defined when server-side rendered.

Initially reported in lovasoa/sanipasse#145

@kaipaysen
Copy link
Contributor

kaipaysen commented Jan 5, 2022

Hi lovasoa,

this might be related to the Tooltip property target (which is not optional).
I'll try to reproduce the issue on my side. You might want to try to pass an empty String as a target in the meantime.

Kai

@lovasoa
Copy link
Contributor Author

lovasoa commented Jan 5, 2022

No, it always throws an error, even if all properties are defined correctly. The component tries to reference objects that are not defined during server-side rendering.

@kaipaysen
Copy link
Contributor

Acording to https://svelte.dev/blog/whats-new-in-svelte-september-2021 HTMLElement is supported starting from svelte 3.42.2. Sveltestrap uses 3.38.2. Would upgrading svelte solve the issue?

@lovasoa
Copy link
Contributor Author

lovasoa commented Jan 6, 2022

The changelog may be a little confusing. Svelte added HTMLElement as a known global during compilation so as not to trigger errors. But is doesn't actually define it, it expects it to be defined by the browser. In SvelteKit, components can be rendered on the server side, where HTMLElement is not defined.

You can reproduce this bug with the latest SvelteKit

@kaipaysen
Copy link
Contributor

Some days ago I reproduced the issue with an older svelte kit application. Just some minutes ago I tried to reproduce the issue with an uptodate svelte kit application (sveltekit next227, svelte 3.46.1) and the issue has vanished. Would you mind doublechecking on your side?

@lovasoa
Copy link
Contributor Author

lovasoa commented Jan 13, 2022

Yes, I can confirm the bug is present with the latest sveltekit. The bug is going to be present as long as sveltestrap tries to reference undefined variables on the server side. The bug is in this repo, not in sveltekit. I was introduced in #396

@lovasoa
Copy link
Contributor Author

lovasoa commented Jan 13, 2022

Here is a simple reproduction you can paste into a default sveltekit project initialized with npm init svelte@next my-app

<script>
	import { Tooltip } from 'sveltestrap'
</script>

<Tooltip target='xxx'>bug</Tooltip>
<h1 id='xxx'>hello</h1>

@bestguy
Copy link
Owner

bestguy commented Jan 13, 2022

Thanks for the fix, will release this weekend.

@bestguy bestguy reopened this Jan 13, 2022
@bestguy
Copy link
Owner

bestguy commented Jan 23, 2022

@bestguy bestguy closed this as completed Jan 23, 2022
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 a pull request may close this issue.

3 participants