feat unused css selector that understands string concatenation#3825
Conversation
|
on a separate note, while working on this case: <div class="foo {a ? 'bar' : 'baz'}">i realised there's many way to implement it: (from most preferred way to least preferred) or <h1
class="foo"
class:bar="{a}"
class:baz="{!a}" /><div class="foo {a ? 'bar' : 'baz'}" /><div class={`foo ${a ? 'bar' : 'baz'}`} />
// or
<div class={'foo ' + (a ? 'bar' : 'baz')} />however because of having writing react app, im more inclined to implement it the 3rd way. i wonder maybe we should have give warnings and guidance to user who write in the 3rd way, and guide them to write it like the 1st way, with svelte's class directive @Rich-Harris what do you think? |
|
Oh man, this is heroic! I tend to lean away from being overly didactic about writing code in a more compiler-friendly style (except in cases where the difference is quite significant), because I think there's a danger that we start to unconsciously favour patterns that are helper for us as implementers, but that are more work for component authors. So I think this PR is great as-is, and we shouldn't worry too much about people who write in the second and third styles (I'm personally quite fond of the second 😀 ) |
Fix #1698