mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 04:41:36 +08:00
Fixed issue with binding when there is no sourceProperty set.
This commit is contained in:
@ -888,3 +888,21 @@ export function test_NestedPropertiesBindingTwoTargetsAndReplacingSomeNestedObje
|
|||||||
|
|
||||||
TKUnit.assertEqual(target2.get("targetProp"), secondExpectedFirstName);
|
TKUnit.assertEqual(target2.get("targetProp"), secondExpectedFirstName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function test_NullSourcePropertyShouldNotCrash() {
|
||||||
|
var expectedValue = "Expected Value";
|
||||||
|
var target = new bindable.Bindable();
|
||||||
|
var convFunc = function (value) {
|
||||||
|
return value + "Converted";
|
||||||
|
}
|
||||||
|
var model = new observable.Observable();
|
||||||
|
model.set("field", expectedValue);
|
||||||
|
model.set("convFunc", convFunc);
|
||||||
|
target.bind({
|
||||||
|
sourceProperty: null,
|
||||||
|
targetProperty: "targetProp",
|
||||||
|
expression: "convFunc(field)"
|
||||||
|
}, model);
|
||||||
|
|
||||||
|
TKUnit.assertEqual(target.get("targetProp"), convFunc(expectedValue));
|
||||||
|
}
|
@ -187,9 +187,14 @@ export class Binding {
|
|||||||
return this.sourcePropertiesArray;
|
return this.sourcePropertiesArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static getProperties(property: string) {
|
private static getProperties(property: string): Array<string> {
|
||||||
|
if (property) {
|
||||||
return property.split(".");
|
return property.split(".");
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private resolveObjectsAndProperties(source: Object, propsArray: Array<string>) {
|
private resolveObjectsAndProperties(source: Object, propsArray: Array<string>) {
|
||||||
var result = [];
|
var result = [];
|
||||||
|
Reference in New Issue
Block a user