mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Merge pull request #1186 from NativeScript/cankov/frame-currentEntry-fix
Fix currentEntry to return NavigationEntry instead of BackstackEntry
This commit is contained in:
@@ -9,7 +9,9 @@ var topmost = frameModule.topmost();
|
|||||||
import labelModule = require("ui/label");
|
import labelModule = require("ui/label");
|
||||||
import pagesModule = require("ui/page");
|
import pagesModule = require("ui/page");
|
||||||
|
|
||||||
export var test_DummyTestForSnippetOnly0 = function () {
|
import TKUnit = require("./TKUnit");
|
||||||
|
|
||||||
|
export var ignore_test_DummyTestForSnippetOnly0 = function () {
|
||||||
// <snippet module="ui/frame" title="frame">
|
// <snippet module="ui/frame" title="frame">
|
||||||
// ### Navigating to a Module
|
// ### Navigating to a Module
|
||||||
// ``` JavaScript
|
// ``` JavaScript
|
||||||
@@ -18,7 +20,7 @@ export var test_DummyTestForSnippetOnly0 = function () {
|
|||||||
// </snippet>
|
// </snippet>
|
||||||
}
|
}
|
||||||
|
|
||||||
export var test_DummyTestForSnippetOnly1 = function () {
|
export var ignore_test_DummyTestForSnippetOnly1 = function () {
|
||||||
// <snippet module="ui/frame" title="frame">
|
// <snippet module="ui/frame" title="frame">
|
||||||
// ### Navigating with a Factory Function
|
// ### Navigating with a Factory Function
|
||||||
// ``` JavaScript
|
// ``` JavaScript
|
||||||
@@ -34,7 +36,7 @@ export var test_DummyTestForSnippetOnly1 = function () {
|
|||||||
// </snippet>
|
// </snippet>
|
||||||
}
|
}
|
||||||
|
|
||||||
export var test_DummyTestForSnippetOnly2 = function () {
|
export var ignore_test_DummyTestForSnippetOnly2 = function () {
|
||||||
// <snippet module="ui/frame" title="frame">
|
// <snippet module="ui/frame" title="frame">
|
||||||
// ### Navigating with NavigationEntry
|
// ### Navigating with NavigationEntry
|
||||||
// ``` JavaScript
|
// ``` JavaScript
|
||||||
@@ -48,7 +50,7 @@ export var test_DummyTestForSnippetOnly2 = function () {
|
|||||||
// </snippet>
|
// </snippet>
|
||||||
}
|
}
|
||||||
|
|
||||||
export var test_DummyTestForSnippetOnly3 = function () {
|
export var ignore_test_DummyTestForSnippetOnly3 = function () {
|
||||||
// <snippet module="ui/frame" title="frame">
|
// <snippet module="ui/frame" title="frame">
|
||||||
// ### Navigating Back
|
// ### Navigating Back
|
||||||
// ``` JavaScript
|
// ``` JavaScript
|
||||||
@@ -56,3 +58,8 @@ export var test_DummyTestForSnippetOnly3 = function () {
|
|||||||
// ```
|
// ```
|
||||||
// </snippet>
|
// </snippet>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function test_currentEntry() {
|
||||||
|
var moduleName = frameModule.topmost().currentEntry.moduleName;
|
||||||
|
TKUnit.assert(moduleName === "tests/app/mainPage" || moduleName === "app/mainPage", "Expected frameModule.topmost().currentEntry.moduleName to return tests/app/mainPage or app/mainPage but instead returned " + moduleName);
|
||||||
|
}
|
||||||
@@ -40,6 +40,7 @@ allTests["FILE SYSTEM"] = require("./file-system-tests");
|
|||||||
allTests["HTTP"] = require("./http-tests");
|
allTests["HTTP"] = require("./http-tests");
|
||||||
allTests["XHR"] = require("./xhr-tests");
|
allTests["XHR"] = require("./xhr-tests");
|
||||||
allTests["FETCH"] = require("./fetch-tests");
|
allTests["FETCH"] = require("./fetch-tests");
|
||||||
|
allTests["FRAME"] = require("./frame-tests");
|
||||||
allTests["APPLICATION SETTINGS"] = require("./application-settings-tests");
|
allTests["APPLICATION SETTINGS"] = require("./application-settings-tests");
|
||||||
allTests["IMAGE SOURCE"] = require("./image-source-tests");
|
allTests["IMAGE SOURCE"] = require("./image-source-tests");
|
||||||
allTests["TIMER"] = require("./timer-tests");
|
allTests["TIMER"] = require("./timer-tests");
|
||||||
|
|||||||
@@ -307,8 +307,8 @@ export class Frame extends view.CustomLayoutView implements definition.Frame {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
get currentEntry(): definition.BackstackEntry {
|
get currentEntry(): definition.NavigationEntry {
|
||||||
return this._currentEntry;
|
return this._currentEntry.entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
public _pushInFrameStack() {
|
public _pushInFrameStack() {
|
||||||
|
|||||||
@@ -290,7 +290,7 @@ export class Frame extends frameCommon.Frame {
|
|||||||
public _onActivityCreated(isRestart: boolean) {
|
public _onActivityCreated(isRestart: boolean) {
|
||||||
this._onAttached(this._android.activity);
|
this._onAttached(this._android.activity);
|
||||||
|
|
||||||
var backstackEntry = this.currentEntry || this._delayedNavigationEntry;
|
var backstackEntry = this._currentEntry || this._delayedNavigationEntry;
|
||||||
|
|
||||||
if (isRestart) {
|
if (isRestart) {
|
||||||
this._onNavigatingTo(backstackEntry, false);
|
this._onNavigatingTo(backstackEntry, false);
|
||||||
@@ -672,7 +672,7 @@ function findPageForFragment(fragment: android.app.Fragment, frame: Frame) {
|
|||||||
trace.write("Attached fragment with no page: " + fragmentTag, trace.categories.NativeLifecycle);
|
trace.write("Attached fragment with no page: " + fragmentTag, trace.categories.NativeLifecycle);
|
||||||
if (frame.currentPage && frame.currentPage[TAG] === fragmentTag) {
|
if (frame.currentPage && frame.currentPage[TAG] === fragmentTag) {
|
||||||
page = frame.currentPage;
|
page = frame.currentPage;
|
||||||
entry = frame.currentEntry;
|
entry = frame._currentEntry;
|
||||||
trace.write("Current page matches fragment: " + fragmentTag, trace.categories.NativeLifecycle);
|
trace.write("Current page matches fragment: " + fragmentTag, trace.categories.NativeLifecycle);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user