custom-cards / flex-table-card

Highly Flexible Lovelace Card - arbitrary contents/columns/rows, regex matched, perfect to show appdaemon created content and anything breaking out of the entity_id + attributes concept
GNU General Public License v3.0
198 stars 23 forks source link

Value 0 is rendered as undefinedundefinedundefined #30

Closed PiotrMachowski closed 4 years ago

PiotrMachowski commented 4 years ago

If an entity has an attribute with value 0 it is not rendered correctly: undefinedundefinedundefined is returned instead: image

I believe the problem is here

daringer commented 4 years ago

uuhh, bad bug due to fix(es) for #18, #28, #24 ... looks like I am still fighting the implicit type conversion in JS, ok let's try it as explicit as possible --- first shot would be changing the line to:

return ([false, null, undefined].every(x => raw_content !== x)) ? raw_content : new Array();

What imposes directly the question: "what is a 'valid' value?", here I included false, which might also be a valid value, so it might boil down to:

return ([null, undefined].every(x => raw_content !== x)) ? raw_content : new Array();

@PiotrMachowski if you're willing to test this directly, please give me some feedback, if it improves the behavior for you. Will try to test and push this somewhere this weekend, but feel free to PR it if you like.

PiotrMachowski commented 4 years ago

@daringer I have checked both versions and they are working correctly. I don't have false in my table, but I think that the second version is better.