Skip to content
Permalink
Browse files

perf(ivy): do no work if moving a `viewRef` to the same position (#34052

)

Move a view only if it would end up at a different place.
Otherwise we would do unnecessary processing like DOM manipulation, query notifications etc.

Thanks to @pkozlowski-opensource for the change.

PR Close #34052
  • Loading branch information
petebacondarwin authored and matsko committed Nov 26, 2019
1 parent 978b500 commit d228801af43c3aa5e79e79332bfea04912a62e67
Showing with 6 additions and 2 deletions.
  1. +6 −2 packages/core/src/render3/view_engine_compatibility.ts
@@ -271,8 +271,12 @@ export function createContainerRef(
throw new Error('Cannot move a destroyed View in a ViewContainer!');
}
const index = this.indexOf(viewRef);
if (index !== -1) this.detach(index);
this.insert(viewRef, newIndex);
if (index === -1) {
this.insert(viewRef, newIndex);
} else if (index !== newIndex) {
this.detach(index);
this.insert(viewRef, newIndex);
}
return viewRef;
}

0 comments on commit d228801

Please sign in to comment.
You can’t perform that action at this time.