salesforce / lwc

⚡️ LWC - A Blazing Fast, Enterprise-Grade Web Components Foundation
https://lwc.dev
Other
1.64k stars 393 forks source link

Cater for the omission of if:false when replacing if:true with lwc:true #4517

Open CraigTildesley opened 2 months ago

CraigTildesley commented 2 months ago

Is your feature request related to a problem? Please describe. There are plenty of situations within lwc development where the if:false has been used but this hasn't been catered for by the lwc:if & lwc:else construct. as far as I can see the omission of lwc:iffalse leads to 2 ugly solutions within the code:

  1. having an empty lwc:if block followed by a populated lwc:else
  2. having to write a not version of the js function eg lwc:if={notShowThing}

Describe the solution you'd like I would like to allow for the existing use case without awful code or having to code bloat with extra code eg notShowThing={return !showThing}

Describe alternatives you've considered As far as I can see there are 2 elegant solutions to this issue. Either:

  1. provide a lwc:ifnot operator within the markup eg lwc:ifnot={showThing}
  2. provide a ! operator as part of the definition lwc:if={!showThing}
nolanlawson commented 2 months ago

Thanks for the feedback. We are working on solution #2 as part of what we're calling "complex template expressions." (It is still under active development and not released yet.) This would allow you to use ! in your expressions.