fix: WrappedValue.unwrap empty string behavior (#6900)

This commit is contained in:
Gheric Speiginer
2019-03-14 05:06:53 -04:00
committed by Manol Donev
parent 3c2c1d9b69
commit 0482460c09
2 changed files with 14 additions and 3 deletions

View File

@ -521,7 +521,18 @@ export function test_CorrectPropertyValueAfterUsingWrappedValue() {
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() {

View File

@ -13,7 +13,7 @@ export class WrappedValue implements WrappedValueDefinition {
}
public static unwrap(value: any) {
return (value && value.wrapped) ? value.wrapped : value;
return (value instanceof WrappedValue) ? value.wrapped : value;
}
public static wrap(value: any) {
@ -249,4 +249,4 @@ export function fromObjectRecursive(source: any): Observable {
let observable = new ObservableFromObject();
addPropertiesFromObject(observable, source, true);
return observable;
}
}