diff --git a/tests/app/ui/layouts/grid-layout-tests.ts b/tests/app/ui/layouts/grid-layout-tests.ts index dc85e7017..9bc784f37 100644 --- a/tests/app/ui/layouts/grid-layout-tests.ts +++ b/tests/app/ui/layouts/grid-layout-tests.ts @@ -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); } diff --git a/tests/app/ui/page/page-tests-common.ts b/tests/app/ui/page/page-tests-common.ts index d2988b581..8bc07ebb0 100644 --- a/tests/app/ui/page/page-tests-common.ts +++ b/tests/app/ui/page/page-tests-common.ts @@ -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 = (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 () { diff --git a/tests/package.json b/tests/package.json index 17ce53ae6..cca777fa5 100644 --- a/tests/package.json +++ b/tests/package.json @@ -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" @@ -23,4 +23,4 @@ "lazy": "1.0.11", "typescript": "^1.8.10" } -} +} \ No newline at end of file diff --git a/tns-core-modules/ui/page/page-common.ts b/tns-core-modules/ui/page/page-common.ts index 0388a0c4b..e85b228c6 100644 --- a/tns-core-modules/ui/page/page-common.ts +++ b/tns-core-modules/ui/page/page-common.ts @@ -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() { @@ -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)); }