mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Undefined can be set as localValue to dependency observable (#2268)
* Undefined can be set as localValue to dependency observable * Fix build error in tests
This commit is contained in:
@@ -233,7 +233,7 @@ export function test_PropertyMetadata_Options() {
|
||||
|
||||
export function test_PropertyEntry_effectiveValue() {
|
||||
var p = new dependencyObservableModule.Property(generatePropertyName(), "testOwner", new dependencyObservableModule.PropertyMetadata(0));
|
||||
var entry = new dependencyObservableModule.PropertyEntry(p);
|
||||
var entry = new dependencyObservableModule.PropertyEntry();
|
||||
|
||||
// default value
|
||||
TKUnit.assertEqual(entry.effectiveValue, undefined, "effectiveValue should be undefined.");
|
||||
|
||||
@@ -2,6 +2,7 @@ import color = require("color");
|
||||
import button = require("ui/button");
|
||||
import stack = require("ui/layouts/stack-layout");
|
||||
import helper = require("../helper");
|
||||
import TKUnit = require("../../TKUnit");
|
||||
|
||||
export var test_value_Inherited_stronger_than_Default = function () {
|
||||
let page = helper.getCurrentPage();
|
||||
@@ -26,7 +27,7 @@ export var test_value_Css_stronger_than_Inherited = function () {
|
||||
helper.assertViewColor(btn, "#0000FF");
|
||||
}
|
||||
|
||||
export var test_value_Local_stronger_than_Css = function () {
|
||||
export function test_value_Local_stronger_than_Css() {
|
||||
let testPage = helper.getCurrentPage();
|
||||
let testStack = new stack.StackLayout();
|
||||
testPage.content = testStack;
|
||||
@@ -39,7 +40,7 @@ export var test_value_Local_stronger_than_Css = function () {
|
||||
btn.style.color = new color.Color("#0000FF");
|
||||
helper.assertViewColor(btn, "#0000FF");
|
||||
btn.style.color = undefined;
|
||||
helper.assertViewColor(btn, "#FF0000");
|
||||
TKUnit.assertEqual(btn.style.color, undefined, "style.color should be undefined when set locally.");
|
||||
}
|
||||
|
||||
export var test_value_VisualState_stronger_than_Local = function () {
|
||||
|
||||
@@ -162,20 +162,11 @@ declare module "ui/core/dependency-observable" {
|
||||
* Represents an Object that is used to back a value for a Property in a DependencyObservable Object instance.
|
||||
*/
|
||||
export class PropertyEntry {
|
||||
/**
|
||||
* Creates a new PropertyEntry instance, associated with the specified Property.
|
||||
* @param property The Property this entry is attached to.
|
||||
*/
|
||||
constructor(property: Property);
|
||||
/**
|
||||
* Resets effective value and all the modifiers available for this entry.
|
||||
*/
|
||||
resetValue(): void;
|
||||
|
||||
/**
|
||||
* Gets the Property instance this entry is associated with. This is a read-only property.
|
||||
*/
|
||||
property: Property;
|
||||
/**
|
||||
* Gets the effective value of this entry.
|
||||
* The value is composed depending on the current valueSource value, using the following priority:
|
||||
|
||||
@@ -267,18 +267,6 @@ export class DependencyObservable extends Observable implements definition.Depen
|
||||
|
||||
this._onPropertyChanged(property, currentValue, newValue);
|
||||
}
|
||||
|
||||
// if (types.isDefined(source)) {
|
||||
// // resetting particular modifier to undefined will remove it from the effective value composition
|
||||
// this._resetValueInternal(property, source);
|
||||
// } else {
|
||||
// let currentValue = entry.effectiveValue;
|
||||
// delete this._propertyEntries[property.id];
|
||||
// let newValue = this._getDefaultValue(property);
|
||||
// if (!property.equalityComparer(currentValue, newValue)) {
|
||||
// this._onPropertyChanged(property, currentValue, newValue);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
public _onPropertyChanged(property: Property, oldValue: any, newValue: any) {
|
||||
@@ -385,10 +373,6 @@ export class DependencyObservable extends Observable implements definition.Depen
|
||||
}
|
||||
|
||||
if (wrapped || !property.equalityComparer(currentValue, realValue)) {
|
||||
if (realValue === undefined) {
|
||||
realValue = this.getEffectiveValue(currentValueSource, entry, property);
|
||||
}
|
||||
|
||||
entry.effectiveValue = realValue;
|
||||
this._onPropertyChanged(property, currentValue, realValue);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user