FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: WrappedValue.unwrap empty string behavior by the-reality-engineer · Pull Request #6900 · NativeScript/NativeScript · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .ts  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
13 changes: 12 additions & 1 deletion tests/app/data/observable-tests.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions tns-core-modules/data/observable/observable.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -249,4 +249,4 @@ export function fromObjectRecursive(source: any): Observable {
let observable = new ObservableFromObject();
addPropertiesFromObject(observable, source, true);
return observable;
}
}

Back | FazBrowse Home | New Git URL