Skip to content

Commit 694b35e

Browse files
committed
Missing piece to fixing Polymer#3094
Update the documentation in the actual dom-repeat element.
1 parent 00b6c96 commit 694b35e

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

src/lib/template/dom-repeat.html

+25-13
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,25 @@
6969
This may be useful for manipulating instance data of event targets obtained
7070
by event handlers on parents of the `dom-repeat` (event delegation).
7171
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
8091
the filter or sort function depends on properties not contained in `items`,
8192
the user should observe changes to those properties and call `render` to update
8293
the view based on the dependency change.
@@ -159,11 +170,12 @@
159170
},
160171

161172
/**
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.)
167179
*/
168180
filter: {
169181
type: Function,

0 commit comments

Comments
 (0)