|
69 | 69 | This may be useful for manipulating instance data of event targets obtained
|
70 | 70 | by event handlers on parents of the `dom-repeat` (event delegation).
|
71 | 71 |
|
72 |
| -A view-specific filter/sort may be applied to each `dom-repeat` by supplying a |
73 |
| -`filter` and/or `sort` property. This may be a string that names a function on |
74 |
| -the host, or a function may be assigned to the property directly. The functions |
75 |
| -should implemented following the standard `Array` filter/sort API. |
76 |
| -
|
77 |
| -In order to re-run the filter or sort functions based on changes to sub-fields |
78 |
| -of `items`, the `observe` property may be set as a space-separated list of |
79 |
| -`item` sub-fields that should cause a re-filter/sort when modified. If |
| 72 | +To filter or sort the _displayed_ items in your list, specify a `filter` or |
| 73 | +`sort` property on the `dom-repeat` (or both): |
| 74 | +
|
| 75 | +* `filter`. Specifies a filter callback function, that takes a single argument |
| 76 | + (the item) and returns true to display the item, false to omit it. |
| 77 | + (Note that this is **similar** to the standard |
| 78 | + `Array` [`filter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) API, but the callback only takes a single argument.) |
| 79 | +* `sort`. Specifies a comparison function following the standard `Array` |
| 80 | + [`sort`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) API. |
| 81 | +
|
| 82 | +In both cases, the value can be either a function object, or a string identifying a |
| 83 | +function defined on the host element. |
| 84 | +
|
| 85 | +By default, the `filter` and `sort` functions only run when the array itself |
| 86 | +is mutated (for example, by adding or removing items). |
| 87 | +
|
| 88 | +To re-run the `filter` or `sort` functions when certain sub-fields |
| 89 | +of `items` change, set the `observe` property to a space-separated list of |
| 90 | +`item` sub-fields that should cause the list to be re-filtered or re-sorted. If |
80 | 91 | the filter or sort function depends on properties not contained in `items`,
|
81 | 92 | the user should observe changes to those properties and call `render` to update
|
82 | 93 | the view based on the dependency change.
|
|
159 | 170 | },
|
160 | 171 |
|
161 | 172 | /**
|
162 |
| - * A function that can be used to filter items out of the view. This |
163 |
| - * property should either be provided as a string, indicating a method |
164 |
| - * name on the element's host, or else be an actual function. The |
165 |
| - * function should match the sort function passed to `Array.filter`. |
166 |
| - * Using a filter function has no effect on the underlying `items` array. |
| 173 | + * `filter`. Specifies a filter callback function, that takes a single |
| 174 | + * argument (the item) and returns true to display the item, false to omit |
| 175 | + * it. Using a filter callback has no effect on the underlying `items` |
| 176 | + * array. |
| 177 | + * (Note that this is **similar** to the standard `Array` |
| 178 | + * [`filter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) API, but the callback only takes a single argument.) |
167 | 179 | */
|
168 | 180 | filter: {
|
169 | 181 | type: Function,
|
|
0 commit comments