Skip to content

Commit 71af1e0

Browse files
committed
fix(list-view): Revert onunload ng view destroy
The fix was not taking into account that view were being recycled and was causing crashes due to prematurely destroying item views.
1 parent 18155f5 commit 71af1e0

File tree

2 files changed

+0
-20
lines changed

2 files changed

+0
-20
lines changed

Diff for: nativescript-angular/directives/list-view-comp.ts

-4
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,6 @@ export type RootLocator = (nodes: Array<any>, nestLevel: number) => View;
243243

244244
export function getItemViewRoot(viewRef: ComponentView, rootLocator: RootLocator = getSingleViewRecursive): View {
245245
const rootView = rootLocator(viewRef.rootNodes, 0);
246-
rootView.on("unloaded", () => {
247-
viewRef.destroy();
248-
delete rootView[NG_VIEW];
249-
});
250246
return rootView;
251247
}
252248

Diff for: tests/app/tests/list-view-tests.ts

-16
Original file line numberDiff line numberDiff line change
@@ -121,19 +121,3 @@ describe("ListView-tests", () => {
121121
.catch(done);
122122
});
123123
});
124-
125-
describe("ListView item templates", () => {
126-
it("destroy child ng views on unload", () => {
127-
const childRoot = new ProxyViewContainer();
128-
let viewDestroyed = false;
129-
const view: ComponentView = {
130-
rootNodes: [],
131-
destroy: () => {
132-
viewDestroyed = true;
133-
}
134-
};
135-
const itemRoot = getItemViewRoot(view, (_rootNodes, _level) => childRoot);
136-
itemRoot.notify({eventName: "unloaded", object: itemRoot});
137-
assert.isTrue(viewDestroyed, "ng view not destroyed");
138-
});
139-
});

0 commit comments

Comments
 (0)