-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
Priority: high
Affects: emberjs/rfcs#848
Affects: ember-data
4.8+
Affects: all array computed macros (filterBy
sortBy
mapBy
etc.)
Related: warp-drive-data/warp-drive#8431
Related: warp-drive-data/warp-drive#8411
The current implementation of computed chains ([email protected]
, field.length
, field.[]
) is not compatible with tracked properties and native arrays when prototype extensions are not present.
This is due to the presumed existence on all arrays of the []
tag. For instance, when building the chain tags for [email protected]
the []
tag is what is entangled for the array, not length
.
ember.js/packages/@ember/-internals/metal/lib/chain-tags.ts
Lines 136 to 137 in f4e8925
// Push the tag for the array length itself | |
chainTags.push(tagForProperty(current, '[]', true, currentTagMeta)); |
The result is that computed chains will not work when field
is a native array without prototype extensions, nor will they work when field
is a Proxy to a native array (as all EmberData arrays are).
Note that its not enough to define a '[]'
getter on the native array or native array proxy that consumes a tag, as the tag will not be the same tag accessed via tagForProperty(iterable, '[]')
.
{{#each}}
This design issue also affects the implementation of {{#each}}
which targets entanglement with []
, although from experience it appears each will recalculate due to access of other tracked properties during iteration whereas computed
will not because we specifically untrack
computed and add back in only the specific chain tags.
consumeTag(tagForProperty(iterable, '[]')); |