adopted-ember-addons / adopted-ember-addons/ember-moment
Odd & inconsistent behaviour from moment-format and is-after helpers
- 主要語言
- JavaScript
- 星號
- 398
- 分支
- 120
- PR 合併指標
- 30 天內沒有已合併 PR
描述
I have something like this in a template:
```
{{#each things as |thing|}}
{{d3-graph
(pipe
(d3-text (moment-format thing.dateTime 'H:mm'))
(d3-attr 'class'
(if
(is-after now thing.dateTime)
'late'
'not-late'
)
)
)
tagName='text'}}
{{/each}}
```
### The inconsistent
The **is-after** helper logs the `an empty value (null, undefined, or "") was passed to moment-format` warning while the **moment-format** helper renders without any warning. Everything works as expected; the time is rendered with the _late_ class (if now is after dateTime)... but with an ugly console warning :-(.
### The odd
In the same conditions, if I set `allow-empty=true` on the **is-after** helper, the text is rendered with the _not-late_ class (instead of _late_).
It seems like the comparison helper fails with `allow-empty=true` and looking at https://github.com/stefanpenner/ember-moment/blob/master/addon/utils/helper-compute.js I don't really understand why `allowEmpty` is taken into account in a comparison helper.
Tested with v7.3.1 on ember v2.14.1 & v2.13.4
貢獻指南
研究方向
Start by reading addon/utils/helper-compute.js, which the issue identifies as the comparison-helper implementation, and reproduce the template with moment-format and is-after using allow-empty. Verify how empty values are handled and ensure is-after does not emit the warning or change the expected late/not-late result when allow-empty is set.
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- javascript
- 領域
- frontend
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 38/100