Address boolean attributes when passing them to the store
The following discussion from !27658 (merged) should be addressed:
-
@ohoral started a discussion: (+6 comments) this one as confusing, cause in case
config.isAdmin
isfalse
,config.isAdmin !== undefined === true
. Is it correct? Why do we check forundefined
?
This happens because a 'boolean' attribute is represented in haml and html without any 'value' examples can be: disabled
or readonly
In the dataset
these elements are represented like so {disabled: ''}
or {disabled: null}
( depending on browser) and so the only way to ascertain if they are truthy
is to do disabled !== undefined
which is ugly and prone to confusion
OPTIONS:
-
🅰 use lodashisNil
=>disabled = !isNil(dataset.disabled)
-
🅱 leave it as it is -
🆎 in thehaml
force the attributes to bedisabled="true"
-
🔤 write a parsing function that takes a 'dataset schema' and a dataset and parse them -
🏀 Put data in a<template type="application/json">
outside the root element (thanks @xanf)!
I would like to move on with vue
does when a prop is defined and we could also get rid of JSON.parse
and similar shenanigans