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:
parent
f0f426b2d0
commit
fadb2d9004
|
@ -271,8 +271,12 @@ export function createContainerRef(
|
||||||
throw new Error('Cannot move a destroyed View in a ViewContainer!');
|
throw new Error('Cannot move a destroyed View in a ViewContainer!');
|
||||||
}
|
}
|
||||||
const index = this.indexOf(viewRef);
|
const index = this.indexOf(viewRef);
|
||||||
if (index !== -1) this.detach(index);
|
if (index === -1) {
|
||||||
this.insert(viewRef, newIndex);
|
this.insert(viewRef, newIndex);
|
||||||
|
} else if (index !== newIndex) {
|
||||||
|
this.detach(index);
|
||||||
|
this.insert(viewRef, newIndex);
|
||||||
|
}
|
||||||
return viewRef;
|
return viewRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue