Skip to content

Loading…

[1.0] dom-if : undefined is considered falsy only once #1742

Closed
cedric-marcone opened this Issue · 1 comment

2 participants

@cedric-marcone

Hey !

In a conditional template, undefined is considered falsy only on the first invocation.
As of today, the only way to handle this use case is to declare a boolean computed property that returns false if the target value is undefined.

I made the following jsbin to reproduce the bug :
http://jsbin.com/retejotege/1/edit?html,output

Hope that helps :)

@cedric-marcone

If you need more info, feel free to tell me.
I'm porting a big codebase and it's biting me real hard :)
I need to write a lot of computed properties to make it work right with dom-if and dom-repeat underlying performance optimizations and I really would like to unclutter my code.

@kevinpschaaf kevinpschaaf added the p1 label
@kevinpschaaf kevinpschaaf self-assigned this
@kevinpschaaf kevinpschaaf closed this issue from a commit
@kevinpschaaf kevinpschaaf Use single-property observer to deal better with if=undefined. Fixes #…
…1742

This takes advantage of the fact that single property observers are called for each change (including undefined), whereas multi-property observers wait for all properties to be defined.  Since the side-effect of the observe is to queue an async render, there is no real benefit from this being a multi-property observer.  #1946 is open to track a more general fix for this issue.
fd741bf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.