Skip to content

Commit

Permalink
Store splices directly on array when legacyUndefined is set
Browse files Browse the repository at this point in the history
Legacy behavior stored splices non-ephemerally. To most easily match this behavior, we store splices directly on the array. This was previously avoided because the property will show as an enumerable property on the array; however, this avoids the need to store and clear splices in a more bespoke way.
  • Loading branch information
Steven Orvell committed Feb 19, 2019
1 parent 363bef2 commit e29a315
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/mixins/property-effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -1008,8 +1008,18 @@ function getArgValue(data, props, path) {
* @private
*/
function notifySplices(inst, array, path, splices) {
inst.notifyPath(path + '.splices', { indexSplices: splices });
const splicesData = { indexSplices: splices };
// Legacy behavior stored splices in `__data__` so it was *not* ephemeral.
// To match this behavior, we store splices directly on the array.
if (legacyUndefined) {
array.splices = splicesData;
}
inst.notifyPath(path + '.splices', splicesData);
inst.notifyPath(path + '.length', array.length);
// Clear splice data only when it's stored on the array.
if (legacyUndefined) {
splicesData.indexSplices = [];
}
}

/**
Expand Down

0 comments on commit e29a315

Please sign in to comment.