From ebfacb0fe8c42dc26cc8cc945181ec98545acb1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Krzto=C5=84?= Date: Thu, 7 Jun 2018 18:27:55 +0200 Subject: [PATCH] Fix for skipped actions in 'actions replace diff'. --- src/view/renderer.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/view/renderer.js b/src/view/renderer.js index a13c5fad9..32c922c27 100644 --- a/src/view/renderer.js +++ b/src/view/renderer.js @@ -697,21 +697,27 @@ export default class Renderer { } let newActions = []; + let skipActions = []; let actualSlice = []; let expectedSlice = []; const counter = { equal: 0, insert: 0, delete: 0 }; for ( const action of actions ) { if ( action === 'insert' ) { + skipActions.push( 'insert' ); expectedSlice.push( expectedDom[ counter.equal + counter.insert ] ); } else if ( action === 'delete' ) { + skipActions.push( 'delete' ); actualSlice.push( actualDom[ counter.equal + counter.delete ] ); } else { // equal if ( expectedSlice.length && actualSlice.length ) { newActions = newActions.concat( calculateReplaceActions( actualSlice, expectedSlice ) ); + } else if ( expectedSlice.length || actualSlice.length ) { + newActions = newActions.concat( skipActions ); } newActions.push( 'equal' ); // Reset stored elements on 'equal'. + skipActions = []; actualSlice = []; expectedSlice = []; }