Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Fix for skipped actions in 'actions replace diff'.
Browse files Browse the repository at this point in the history
  • Loading branch information
f1ames committed Jun 7, 2018
1 parent d050901 commit ebfacb0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/view/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
}
Expand Down

0 comments on commit ebfacb0

Please sign in to comment.