MCPcopy Index your code
hub / github.com/angular/angular / swap

Function swap

packages/core/src/render3/list_reconciliation.ts:36–47  ·  view source on GitHub ↗
(index1: number, index2: number)

Source from the content-addressed store, hash-verified

34 // them explicitly allow clear expression of intent and potentially more performant
35 // implementations
36 swap(index1: number, index2: number): void {
37 const startIdx = Math.min(index1, index2);
38 const endIdx = Math.max(index1, index2);
39 const endItem = this.detach(endIdx);
40 if (endIdx - startIdx > 1) {
41 const startItem = this.detach(startIdx);
42 this.attach(startIdx, endItem);
43 this.attach(endIdx, startItem);
44 } else {
45 this.attach(startIdx, endItem);
46 }
47 }
48 move(prevIndex: number, newIdx: number): void {
49 // For move operations, the detach code path is the same one used for removing
50 // DOM nodes, which would trigger `animate.leave` bindings. We need to skip

Callers

nothing calls this directly

Calls 4

detachMethod · 0.65
attachMethod · 0.65
minMethod · 0.45
maxMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…