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

Compiler warnings on trying to set styles and classes on <svelte:body /> #7929

Open
janosh opened this issue Oct 11, 2022 · 1 comment
Open
Labels
compiler Changes relating to the compiler feature request

Comments

@janosh
Copy link
Contributor

janosh commented Oct 11, 2022

Describe the problem

For the time being while features like changing <body> class (#3105) and styles

<svelte:body style="max-width: 50em; margin: auto;" />

are not supported, would be nice if the Svelte compiler showed a warning when people try to do this.

Describe the proposed solution

Red squiggly lines below and a tooltip saying

The svelte:body element only allows listening for events that fire on document.body. It does not support modifying document.body.

on hovering lines like:

<svelte:body style="max-width: 50em; margin: auto;" />

<svelte:body class:foo={is_bar} />

Alternatives considered

Current state of no compiler warning requires people to search GitHub.

Importance

nice to have

@Conduitry Conduitry added feature request compiler Changes relating to the compiler labels Oct 11, 2022
@Conduitry
Copy link
Member

This seems reasonable. But I think it should be a compiler error, not just a warning. There's no reason currently to even have code like this, and warnings are often missed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler Changes relating to the compiler feature request
Projects
None yet
Development

No branches or pull requests

2 participants