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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Value 0 is rendered as undefinedundefinedundefined

PiotrMachowski opened this issue · comments

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

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.

@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.