mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-18 13:51:27 +08:00
chore: refactor per comments
This commit is contained in:
@ -344,7 +344,8 @@ export class Binding {
|
||||
}
|
||||
|
||||
let newValue = value;
|
||||
if (!__UI_CUSTOM_FLAVOR__ && this.options.expression) {
|
||||
if (__UI_CUSTOM_FLAVOR__) {
|
||||
} else if (this.options.expression) {
|
||||
const changedModel = {};
|
||||
changedModel[bc.bindingValueKey] = value;
|
||||
changedModel[bc.newPropertyValueKey] = value;
|
||||
@ -369,6 +370,7 @@ export class Binding {
|
||||
|
||||
newValue = expressionValue;
|
||||
}
|
||||
|
||||
|
||||
this.updateSource(newValue);
|
||||
}
|
||||
@ -424,14 +426,7 @@ export class Binding {
|
||||
}
|
||||
}
|
||||
|
||||
if (!__UI_CUSTOM_FLAVOR__ && this.options.expression) {
|
||||
const expressionValue = this._getExpressionValue(this.options.expression, false, undefined);
|
||||
if (expressionValue instanceof Error) {
|
||||
Trace.write(expressionValue.message, Trace.categories.Binding, Trace.messageType.error);
|
||||
} else {
|
||||
this.updateTarget(expressionValue);
|
||||
}
|
||||
} else {
|
||||
if (__UI_CUSTOM_FLAVOR__ || !this.options.expression) {
|
||||
if (changedPropertyIndex > -1) {
|
||||
const props = sourceProps.slice(changedPropertyIndex + 1);
|
||||
const propsLength = props.length;
|
||||
@ -446,6 +441,13 @@ export class Binding {
|
||||
this.updateTarget(data.value);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const expressionValue = this._getExpressionValue(this.options.expression, false, undefined);
|
||||
if (expressionValue instanceof Error) {
|
||||
Trace.write(expressionValue.message, Trace.categories.Binding, Trace.messageType.error);
|
||||
} else {
|
||||
this.updateTarget(expressionValue);
|
||||
}
|
||||
}
|
||||
|
||||
// we need to do this only if nested objects are used as source and some middle object has changed.
|
||||
@ -519,7 +521,8 @@ export class Binding {
|
||||
}
|
||||
|
||||
private getSourcePropertyValue() {
|
||||
if (!__UI_CUSTOM_FLAVOR__ && this.options.expression) {
|
||||
if (__UI_CUSTOM_FLAVOR__) {
|
||||
} else if (this.options.expression) {
|
||||
const changedModel = {};
|
||||
changedModel[bc.bindingValueKey] = this.source ? this.source.get() : undefined;
|
||||
const expressionValue = this._getExpressionValue(this.options.expression, false, changedModel);
|
||||
|
@ -26,7 +26,8 @@ export abstract class ListViewBase extends ContainerView implements ListViewDefi
|
||||
public _defaultTemplate: KeyedTemplate = {
|
||||
key: 'default',
|
||||
createView: () => {
|
||||
if (!__UI_CUSTOM_FLAVOR__ && this.itemTemplate) {
|
||||
if (__UI_CUSTOM_FLAVOR__) {
|
||||
} else if (this.itemTemplate) {
|
||||
return Builder.parse(this.itemTemplate, this);
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,11 @@ export class Repeater extends CustomLayoutView {
|
||||
}
|
||||
|
||||
if (!viewToAdd) {
|
||||
viewToAdd = (!__UI_CUSTOM_FLAVOR__ && this.itemTemplate) ? Builder.parse(this.itemTemplate, this) : this._getDefaultItemContent(i);
|
||||
if (__UI_CUSTOM_FLAVOR__) {
|
||||
viewToAdd = this._getDefaultItemContent(i)
|
||||
} else {
|
||||
viewToAdd = this.itemTemplate ? Builder.parse(this.itemTemplate, this) : this._getDefaultItemContent(i);
|
||||
}
|
||||
}
|
||||
|
||||
viewToAdd.bindingContext = dataItem;
|
||||
|
Reference in New Issue
Block a user