mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 21:01:34 +08:00
fix: WrappedValue.unwrap empty string behavior (#6900)
This commit is contained in:

committed by
Manol Donev

parent
3c2c1d9b69
commit
0482460c09
@ -521,7 +521,18 @@ export function test_CorrectPropertyValueAfterUsingWrappedValue() {
|
|||||||
|
|
||||||
testObservable.set("property1", wrappedArray);
|
testObservable.set("property1", wrappedArray);
|
||||||
|
|
||||||
TKUnit.assertEqual(testObservable.get("property1"), testArray, "WrappedValue is used only to execute property change logic and unwrapped value should be used as proeprty value.");
|
TKUnit.assertEqual(testObservable.get("property1"), testArray, "WrappedValue is used only to execute property change logic and unwrapped value should be used as property value.");
|
||||||
|
}
|
||||||
|
|
||||||
|
export function test_CorrectPropertyValueAfterUsingStringEmptyWrappedValue() {
|
||||||
|
const emptyString = "";
|
||||||
|
let testObservable = fromObject({ "property1": emptyString });
|
||||||
|
|
||||||
|
let wrappedEmptyString = WrappedValue.wrap(emptyString);
|
||||||
|
|
||||||
|
testObservable.set("property1", wrappedEmptyString);
|
||||||
|
|
||||||
|
TKUnit.assertEqual(testObservable.get("property1"), emptyString, "WrappedValue is used only to execute property change logic and unwrapped value should be used as property value.");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function test_NestedObservablesWithObservableArrayShouldNotCrash() {
|
export function test_NestedObservablesWithObservableArrayShouldNotCrash() {
|
||||||
|
@ -13,7 +13,7 @@ export class WrappedValue implements WrappedValueDefinition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static unwrap(value: any) {
|
public static unwrap(value: any) {
|
||||||
return (value && value.wrapped) ? value.wrapped : value;
|
return (value instanceof WrappedValue) ? value.wrapped : value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static wrap(value: any) {
|
public static wrap(value: any) {
|
||||||
|
Reference in New Issue
Block a user