withastro / compiler

The Astro compiler. Written in Go. Distributed as WASM.
Other
503 stars 59 forks source link

Assigning literal template directives is:global={false} is:inline={false} #853

Open kanashimia opened 1 year ago

kanashimia commented 1 year ago

What version of astro are you using?

2.9.3

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

npm

What operating system are you using?

Linux

What browser are you using?

Chromium

Describe the Bug

Apparently you can set <style is:global={false}> and it acts like <style>, but <style is:inline={false}> doesn't disable inline behaviour. This may be useful to optionally set directives.

What's the expected result?

foo:bar={false} should disable the directive for all boolean directives, not only those two, should produce the same behaviour, and should be documented. Otherwise it should be an error, after all this seems like a funny consequence of an implementation.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-3xbqtc?file=src%2Fcomponents%2FTest.astro

Participation

natemoo-re commented 1 year ago

Yeah this makes sense, just an implementation oversight. This is:inline logic in our compiler could be updated.

Be warned that these are static directives that can only be handled at build-time, though. These won't ever support dynamic variables, only the literal value false. Because of that potential confusion, we don't really recommend this pattern.

natemoo-re commented 1 year ago

I'm going to move this over to the compiler repo, since the code that handles this lives there!