mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 20:11:24 +08:00
Fixed issue with binding when there is no sourceProperty set.
This commit is contained in:
@ -887,4 +887,22 @@ export function test_NestedPropertiesBindingTwoTargetsAndReplacingSomeNestedObje
|
||||
(<Activity>act1).Owner = newPerson;
|
||||
|
||||
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,8 +187,13 @@ export class Binding {
|
||||
return this.sourcePropertiesArray;
|
||||
}
|
||||
|
||||
private static getProperties(property: string) {
|
||||
return property.split(".");
|
||||
private static getProperties(property: string): Array<string> {
|
||||
if (property) {
|
||||
return property.split(".");
|
||||
}
|
||||
else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private resolveObjectsAndProperties(source: Object, propsArray: Array<string>) {
|
||||
|
Reference in New Issue
Block a user