Skip to content

Commit e29a315

Browse files
author
Steven Orvell
committed
Store splices directly on array when legacyUndefined is set
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.
1 parent 363bef2 commit e29a315

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/mixins/property-effects.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1008,8 +1008,18 @@ function getArgValue(data, props, path) {
10081008
* @private
10091009
*/
10101010
function notifySplices(inst, array, path, splices) {
1011-
inst.notifyPath(path + '.splices', { indexSplices: splices });
1011+
const splicesData = { indexSplices: splices };
1012+
// Legacy behavior stored splices in `__data__` so it was *not* ephemeral.
1013+
// To match this behavior, we store splices directly on the array.
1014+
if (legacyUndefined) {
1015+
array.splices = splicesData;
1016+
}
1017+
inst.notifyPath(path + '.splices', splicesData);
10121018
inst.notifyPath(path + '.length', array.length);
1019+
// Clear splice data only when it's stored on the array.
1020+
if (legacyUndefined) {
1021+
splicesData.indexSplices = [];
1022+
}
10131023
}
10141024

10151025
/**

0 commit comments

Comments
 (0)