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
This commit is contained in:

committed by
Matias Niemelä

parent
978b500961
commit
d228801af4
@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user