Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions tests/app/ui/layouts/grid-layout-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ class RemovalTrackingGridLayout extends GridLayout {
public removedCols = 0;

public _onRowRemoved(itemSpec: ItemSpec, index: number) {
console.log("_onRowRemoved");
this.removedRows++;
super._onRowRemoved(itemSpec, index);
}

public _onColumnRemoved(itemSpec: ItemSpec, index: number) {
console.log("_onColumnRemoved");
this.removedCols++;
super._onColumnRemoved(itemSpec, index);
}
Expand Down
25 changes: 25 additions & 0 deletions tests/app/ui/page/page-tests-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,31 @@ export function test_NavigateTo_WithContext() {
TKUnit.assertNull(testPage.navigationContext, "Navigation context should be cleared on navigating back");
}

//https://github.com/NativeScript/NativeScript/issues/731
export function test_BindingContext_Becomes_NavigationContext_When_NavigatingTo() {
let currentPage = frameModule.topmost().currentPage;
let testPage: Page;
let bindingContext;
let pageFactory = function (): Page {
testPage = new Page();
testPage.on(pageModule.Page.navigatingToEvent, function (args: NavigatedData) {
bindingContext = (<Page>args.object).bindingContext;
});
return testPage;
};
let navEntry = {
create: pageFactory,
context: "This is the navigation context",
animated: false
};
let topFrame = frameModule.topmost();
topFrame.navigate(navEntry);
TKUnit.waitUntilReady(() => topFrame.currentPage !== null && topFrame.currentPage !== currentPage && testPage.isLayoutValid);
helper.goBack();

TKUnit.assertEqual(bindingContext, navEntry.context, "The Page's bindingContext should be set automatically to the navigation context when navigating to.");
}

export function test_FrameBackStack_WhenNavigatingForwardAndBack() {
let testPage: Page;
let pageFactory = function () {
Expand Down
4 changes: 2 additions & 2 deletions tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"nativescript": {
"id": "org.nativescript.tests",
"tns-ios": {
"version": "2.1.0"
"version": "2.1.1"
},
"tns-android": {
"version": "2.1.1"
Expand All @@ -23,4 +23,4 @@
"lazy": "1.0.11",
"typescript": "^1.8.10"
}
}
}
6 changes: 6 additions & 0 deletions tns-core-modules/ui/page/page-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import * as fileSystemModule from "file-system";
import * as frameModule from "ui/frame";
import proxy = require("ui/core/proxy");
import keyframeAnimation = require("ui/animation/keyframe-animation");
import types = require("utils/types");

let fs: typeof fileSystemModule;
function ensureFS() {
Expand Down Expand Up @@ -201,6 +202,11 @@ export class Page extends ContentView implements dts.Page {

public onNavigatingTo(context: any, isBackNavigation: boolean) {
this._navigationContext = context;

//https://github.com/NativeScript/NativeScript/issues/731
if (!isBackNavigation && !types.isNullOrUndefined(context)){
this.bindingContext = context;
}
this.notify(this.createNavigatedData(Page.navigatingToEvent, isBackNavigation));
}

Expand Down