Skip to content

Commit 43e95db

Browse files
committed
fix: handle undefined input
1 parent a14c935 commit 43e95db

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ All helpers accept the following optional named arguments (even though they are
339339
| `locale` | An optional `String` [locale](https://momentjs.com/docs/#/i18n/), to override the default global `moment.locale` |
340340
| `timeZone` | An optional `String` [time zone](https://momentjs.com/timezone/docs/), defaults to `moment.timeZone` (the default time zone) |
341341
| `interval` | An optional interval `Number` of milliseconds when the helper should be recomputed |
342-
| `allow-empty` | An optional `Boolean` to ignore the `Invalid date` output when knowingly passing `null`, `undefined`, or `''`, defaults to `false` |
342+
| `allow-empty` | An optional `Boolean` to suppress errors when knowingly passing `null`, `undefined`, or `''`, defaults to `false` |
343343

344344
Note that `interval` does not recompute the value of the helper parameters, unless it is
345345
part of a helper that *is* a value in which case it is useful for "live" updating as time elapses.
@@ -414,7 +414,7 @@ export default Ember.Controller.extend({
414414

415415
### Global Allow Empty Dates
416416

417-
If `null`, `undefined`, or an empty string are passed as a date to any of the moment helpers then you will get `Invalid Date` in the output. To avoid this issue globally, you can set the option `allowEmpty` which all of the helpers respect and will result in nothing being rendered instead of `Invalid Date`.
417+
If `null`, `undefined`, or an empty string are passed as a date to any of the moment helpers they will raise an error. To avoid this issue globally, you can set the option `allowEmpty` which all of the helpers respect and will result in no error and nothing being rendered.
418418

419419
```js
420420
// config/environment.js
@@ -511,7 +511,7 @@ export default Ember.Route.extend({
511511
512512
An invalid date string is being passed into momentjs and/or the [input string format](https://momentjs.com/docs/#/parsing/string-format/) was omitted.
513513
514-
If you are knowingly passing null, undefined, or an empty string and want to ignore the output of `Invalid Date` then pass the option `allow-empty=true` to the helper (all helpers accept this property)
514+
If you are knowingly passing null, undefined, or an empty string and want to avoid errors then pass the option `allow-empty=true` to the helper (all helpers accept this property)
515515
516516
```hbs
517517
{{moment-format ''}} {{!-- Invalid date --}}

addon/utils/helper-compute.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { assert } from '@ember/debug';
12
import { isBlank } from '@ember/utils';
23
import { get } from '@ember/object';
34

@@ -20,8 +21,7 @@ export default function(cb) {
2021
return;
2122
}
2223

23-
/* eslint-disable no-console */
24-
console.warn(`ember-moment: an empty value (null, undefined, or "") was passed to ember-moment helper`);
24+
assert(`ember-moment: an empty value (null, undefined, or "") was passed to ember-moment helper`);
2525
}
2626

2727
return cb.apply(this, arguments);

0 commit comments

Comments
 (0)