From e29a3150020b933790f78c8050d23f480f25bc7d Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Tue, 19 Feb 2019 12:31:04 -0800 Subject: [PATCH] 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. --- lib/mixins/property-effects.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/mixins/property-effects.js b/lib/mixins/property-effects.js index e7412d47a4..626ace1e68 100644 --- a/lib/mixins/property-effects.js +++ b/lib/mixins/property-effects.js @@ -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 = []; + } } /**