mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-18 05:18:39 +08:00
fix-next(HMR): apply changes in page styles at runtime when app root is a frame
This commit is contained in:
@ -153,7 +153,7 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
|
|||||||
if (context && context.type && context.path) {
|
if (context && context.type && context.path) {
|
||||||
// Handle local styles
|
// Handle local styles
|
||||||
if (context.type === ModuleType.style) {
|
if (context.type === ModuleType.style) {
|
||||||
return this.changeLocalStyles(context.path);
|
return this._changeLocalStyles(context.path);
|
||||||
}
|
}
|
||||||
// Handle module markup and script changes
|
// Handle module markup and script changes
|
||||||
else {
|
else {
|
||||||
@ -164,7 +164,7 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private changeLocalStyles(contextPath: string): boolean {
|
public _changeLocalStyles(contextPath: string): boolean {
|
||||||
if (!this.changeStyles(this, contextPath)) {
|
if (!this.changeStyles(this, contextPath)) {
|
||||||
eachDescendant(this, (child: ViewBase) => {
|
eachDescendant(this, (child: ViewBase) => {
|
||||||
this.changeStyles(child, contextPath);
|
this.changeStyles(child, contextPath);
|
||||||
|
4
tns-core-modules/ui/core/view/view.d.ts
vendored
4
tns-core-modules/ui/core/view/view.d.ts
vendored
@ -683,6 +683,10 @@ export abstract class View extends ViewBase {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_onLivesync(context?: { type: string, path: string }): boolean;
|
_onLivesync(context?: { type: string, path: string }): boolean;
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
_changeLocalStyles(contextPath: string): boolean;
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
|
@ -349,6 +349,11 @@ export class Frame extends FrameBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (context && context.type && context.path) {
|
if (context && context.type && context.path) {
|
||||||
|
// Handle local styls changes when app root is Frame
|
||||||
|
if (context.type === ModuleType.style) {
|
||||||
|
return this._changeLocalStyles(context.path);
|
||||||
|
}
|
||||||
|
|
||||||
// Set NavigationType.replace for HMR.
|
// Set NavigationType.replace for HMR.
|
||||||
this.navigationType = NavigationType.replace;
|
this.navigationType = NavigationType.replace;
|
||||||
const currentBackstackEntry = this._currentEntry;
|
const currentBackstackEntry = this._currentEntry;
|
||||||
|
@ -3,6 +3,7 @@ import {
|
|||||||
iOSFrame as iOSFrameDefinition, BackstackEntry, NavigationTransition
|
iOSFrame as iOSFrameDefinition, BackstackEntry, NavigationTransition
|
||||||
} from ".";
|
} from ".";
|
||||||
import { Page } from "../page";
|
import { Page } from "../page";
|
||||||
|
import { ModuleType } from "../../ui/core/view/view-common";
|
||||||
import { profile } from "../../profiling";
|
import { profile } from "../../profiling";
|
||||||
|
|
||||||
//Types.
|
//Types.
|
||||||
@ -73,6 +74,11 @@ export class Frame extends FrameBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (context && context.type && context.path) {
|
if (context && context.type && context.path) {
|
||||||
|
// Handle local styls changes when app root is Frame
|
||||||
|
if (context.type === ModuleType.style) {
|
||||||
|
return this._changeLocalStyles(context.path);
|
||||||
|
}
|
||||||
|
|
||||||
// Set NavigationType.replace for HMR.
|
// Set NavigationType.replace for HMR.
|
||||||
// When `viewDidAppear()` set to NavigationType.forward.
|
// When `viewDidAppear()` set to NavigationType.forward.
|
||||||
this.navigationType = NavigationType.replace;
|
this.navigationType = NavigationType.replace;
|
||||||
|
Reference in New Issue
Block a user