Commit e5fc370
fix(helpers): keep falsy but defined values in fillTemplate
fillTemplate replaced each ${var} with `templateVars[match] || ''`,
which also dropped values that are defined but falsy, such as the
number 0 or the boolean false. For example fillTemplate('${n}', {n: 0})
returned an empty string instead of '0'.
This is noticeable in Pagination, where PaginationOptionsMenu passes
numeric firstIndex, lastIndex and itemCount into a string toggle
template. With an empty data set (itemCount of 0) the '0' was silently
dropped from the toggle text.
Use the nullish coalescing operator so only null or undefined values
(for example a missing key) fall back to an empty string, while 0 and
false are kept.
Co-authored-by: eeshsaxena <eeshsaxena@gmail.com>1 parent 4e13e7c commit e5fc370
2 files changed
Lines changed: 11 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
102 | 112 | | |
103 | 113 | | |
104 | 114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
| 117 | + | |
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| |||
0 commit comments