diff --git a/CHANGELOG.md b/CHANGELOG.md
index aaa838386..922edf6ca 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,12 @@
+## [5.4.3](https://github.com/NativeScript/NativeScript/compare/5.4.2...5.4.3) (2019-06-21)
+
+
+### Bug Fixes
+
+* clear the `resolvedPage` when entry is being cleared, change the passed `View` to be a weak reference ([#7327](https://github.com/NativeScript/NativeScript/issues/7327)) ([dfe7621](https://github.com/NativeScript/NativeScript/commit/dfe7621))
+
+
+
## [5.4.2](https://github.com/NativeScript/NativeScript/compare/5.4.1...5.4.2) (2019-06-06)
diff --git a/tns-core-modules/ui/core/properties/properties.ts b/tns-core-modules/ui/core/properties/properties.ts
index bf6c7ba0d..4734b693a 100644
--- a/tns-core-modules/ui/core/properties/properties.ts
+++ b/tns-core-modules/ui/core/properties/properties.ts
@@ -4,6 +4,12 @@ import { ViewBase } from "../view-base";
// Types.
import { WrappedValue, PropertyChangeData } from "../../../data/observable";
+import {
+ write as traceWrite,
+ categories as traceCategories,
+ messageType as traceMessageType,
+} from "../../../trace";
+
import { Style } from "../../styling/style";
import { profile } from "../../../profiling";
@@ -125,7 +131,7 @@ export class Property implements TypedPropertyDescriptor<
if (affectsLayout) {
this.requestLayout();
}
-
+
if (reset) {
delete this[key];
if (valueChanged) {
@@ -466,6 +472,13 @@ export class CssProperty implements definitions.CssProperty<
const property = this;
function setLocalValue(this: T, newValue: U | string): void {
+ const view = this.viewRef.get();
+ if (!view) {
+ traceWrite(`${newValue} not set to view because ".viewRef" is cleared`, traceCategories.Style, traceMessageType.warn);
+
+ return;
+ }
+
const reset = newValue === unsetValue || newValue === "";
let value: U;
if (reset) {
@@ -482,7 +495,6 @@ export class CssProperty implements definitions.CssProperty<
const changed: boolean = equalityComparer ? !equalityComparer(oldValue, value) : oldValue !== value;
if (changed) {
- const view = this.view;
if (reset) {
delete this[key];
if (valueChanged) {
@@ -534,6 +546,13 @@ export class CssProperty implements definitions.CssProperty<
}
function setCssValue(this: T, newValue: U | string): void {
+ const view = this.viewRef.get();
+ if (!view) {
+ traceWrite(`${newValue} not set to view because ".viewRef" is cleared`, traceCategories.Style, traceMessageType.warn);
+
+ return;
+ }
+
const currentValueSource: number = this[sourceKey] || ValueSource.Default;
// We have localValueSource - NOOP.
@@ -557,7 +576,6 @@ export class CssProperty implements definitions.CssProperty<
const changed: boolean = equalityComparer ? !equalityComparer(oldValue, value) : oldValue !== value;
if (changed) {
- const view = this.view;
if (reset) {
delete this[key];
if (valueChanged) {
@@ -718,12 +736,18 @@ export class CssAnimationProperty implements definitions.Css
enumerable, configurable,
get: getsComputed ? function (this: T) { return this[computedValue]; } : function (this: T) { return this[symbol]; },
set(this: T, boxedValue: U | string) {
+ const view = this.viewRef.get();
+ if (!view) {
+ traceWrite(`${boxedValue} not set to view because ".viewRef" is cleared`, traceCategories.Animation, traceMessageType.warn);
+
+ return;
+ }
const oldValue = this[computedValue];
const oldSource = this[computedSource];
const wasSet = oldSource !== ValueSource.Default;
const reset = boxedValue === unsetValue || boxedValue === "";
-
+
if (reset) {
this[symbol] = unsetValue;
if (this[computedSource] === propertySource) {
@@ -760,7 +784,6 @@ export class CssAnimationProperty implements definitions.Css
valueChanged(this, oldValue, value);
}
- const view = this.view;
if (view[setNative] && (computedValueChanged || isSet !== wasSet)) {
if (view._suspendNativeUpdatesCount) {
if (view._suspendedUpdates) {
@@ -816,10 +839,16 @@ export class CssAnimationProperty implements definitions.Css
}
public _initDefaultNativeValue(target: T): void {
+ const view = target.viewRef.get();
+ if (!view) {
+ traceWrite(`_initDefaultNativeValue not executed to view because ".viewRef" is cleared`, traceCategories.Animation, traceMessageType.warn);
+
+ return;
+ }
+
const defaultValueKey = this.defaultValueKey;
if (!(defaultValueKey in target)) {
- const view = target.view;
const getDefault = this.getDefault;
target[defaultValueKey] = view[getDefault] ? view[getDefault]() : this.defaultValue;
}
@@ -862,6 +891,13 @@ export class InheritedCssProperty extends CssProperty
const property = this;
const setFunc = (valueSource: ValueSource) => function (this: T, boxedValue: any): void {
+ const view = this.viewRef.get();
+ if (!view) {
+ traceWrite(`${boxedValue} not set to view's property because ".viewRef" is cleared`, traceCategories.Style, traceMessageType.warn);
+
+ return;
+ }
+
const reset = boxedValue === unsetValue || boxedValue === "";
const currentValueSource: number = this[sourceKey] || ValueSource.Default;
if (reset) {
@@ -876,7 +912,6 @@ export class InheritedCssProperty extends CssProperty
}
const oldValue: U = key in this ? this[key] : defaultValue;
- const view = this.view;
let value: U;
let unsetNativeValue = false;
if (reset) {
@@ -907,7 +942,6 @@ export class InheritedCssProperty extends CssProperty
const changed: boolean = equalityComparer ? !equalityComparer(oldValue, value) : oldValue !== value;
if (changed) {
- const view = this.view;
if (valueChanged) {
valueChanged(this, oldValue, value);
}
@@ -997,7 +1031,14 @@ export class ShorthandProperty implements definitions.Shorth
const converter = options.converter;
function setLocalValue(this: T, value: string | P): void {
- this.view._batchUpdate(() => {
+ const view = this.viewRef.get();
+ if (!view) {
+ traceWrite(`setLocalValue not executed to view because ".viewRef" is cleared`, traceCategories.Animation, traceMessageType.warn);
+
+ return;
+ }
+
+ view._batchUpdate(() => {
for (let [p, v] of converter(value)) {
this[p.name] = v;
}
@@ -1005,7 +1046,14 @@ export class ShorthandProperty implements definitions.Shorth
}
function setCssValue(this: T, value: string): void {
- this.view._batchUpdate(() => {
+ const view = this.viewRef.get();
+ if (!view) {
+ traceWrite(`setCssValue not executed to view because ".viewRef" is cleared`, traceCategories.Animation, traceMessageType.warn);
+
+ return;
+ }
+
+ view._batchUpdate(() => {
for (let [p, v] of converter(value)) {
this[p.cssName] = v;
}
diff --git a/tns-core-modules/ui/core/view-base/view-base.ts b/tns-core-modules/ui/core/view-base/view-base.ts
index 02ba4c96b..574ff21be 100644
--- a/tns-core-modules/ui/core/view-base/view-base.ts
+++ b/tns-core-modules/ui/core/view-base/view-base.ts
@@ -192,7 +192,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
public _domId: number;
public _context: any;
public _isAddedToNativeVisualTree: boolean;
- public _cssState: ssm.CssState = new ssm.CssState(this);
+ public _cssState: ssm.CssState = new ssm.CssState(new WeakRef(this));
public _styleScope: ssm.StyleScope;
public _suspendedUpdates: { [propertyName: string]: Property | CssProperty