Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 6a33749

Browse files
arw-travelagkalpak
authored andcommitted
docs(orderBy): clarify behavior of default comparator wrt null
Document how `orderBy`'s default comparator handles `null` values. Fixes #15293 Closes #15304
1 parent 21ac2c4 commit 6a33749

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

docs/content/guide/migration.ngdoc

+4-1
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,11 @@ and "$dependentProvider" would have actually accomplished something and changed
11251125
app. This is no longer possible within a single module.
11261126

11271127

1128+
### Filters (`orderBy`)
11281129

1130+
- due to [a097aa95](https://github.com/angular/angular.js/commit/a097aa95b7c78beab6d1b7d521c25f7d9d7843d9),
1131+
`orderBy` now treats `null` values (which in JavaScript have type `object`) as having a string
1132+
represenation of `'null'`.
11291133

11301134

11311135
### Animation (`ngAnimate`)
@@ -1229,7 +1233,6 @@ or simply use:
12291233

12301234

12311235

1232-
12331236
## Migrating from 1.0 to 1.2
12341237

12351238

src/ng/filter/orderBy.js

+3
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@
8686
*
8787
* **Note:** If you notice numbers not being sorted as expected, make sure they are actually being
8888
* saved as numbers and not strings.
89+
* **Note:** For the purpose of sorting, `null` values are treated as the string `'null'` (i.e.
90+
* `type: 'string'`, `value: 'null'`). This may cause unexpected sort order relative to
91+
* other values.
8992
*
9093
* @param {Array|ArrayLike} collection - The collection (array or array-like object) to sort.
9194
* @param {(Function|string|Array.<Function|string>)=} expression - A predicate (or list of

0 commit comments

Comments
 (0)