(value: any)
| 316 | } |
| 317 | |
| 318 | private updateTwoWay(value: any) { |
| 319 | if (this.updating || !this.options.twoWay) { |
| 320 | return; |
| 321 | } |
| 322 | |
| 323 | let newValue = value; |
| 324 | if (__UI_USE_EXTERNAL_RENDERER__) { |
| 325 | } else if (this.options.expression) { |
| 326 | const changedModel = {}; |
| 327 | const targetInstance = this.target.get(); |
| 328 | let sourcePropertyName = ''; |
| 329 | if (this.sourceOptions) { |
| 330 | sourcePropertyName = this.sourceOptions.property; |
| 331 | } else if (typeof this.options.sourceProperty === 'string' && this.options.sourceProperty.indexOf('.') === -1) { |
| 332 | sourcePropertyName = this.options.sourceProperty; |
| 333 | } |
| 334 | |
| 335 | const updateExpression = this.prepareExpressionForUpdate(); |
| 336 | this.prepareContextForExpression(targetInstance, changedModel, updateExpression); |
| 337 | |
| 338 | /** |
| 339 | * Wait for 'prepareContextForExpression' to assign keys first and override any possible occurences. |
| 340 | * For example, 'bindingValueKey' key can result in a circular reference if it's set in both cases. |
| 341 | */ |
| 342 | changedModel[bc.bindingValueKey] = value; |
| 343 | changedModel[bc.newPropertyValueKey] = value; |
| 344 | if (sourcePropertyName !== '') { |
| 345 | changedModel[sourcePropertyName] = value; |
| 346 | } |
| 347 | |
| 348 | const expressionValue = this._getExpressionValue(updateExpression, true, changedModel); |
| 349 | if (expressionValue instanceof Error) { |
| 350 | Trace.write((<Error>expressionValue).message, Trace.categories.Binding, Trace.messageType.error); |
| 351 | } |
| 352 | |
| 353 | newValue = expressionValue; |
| 354 | } |
| 355 | |
| 356 | this.updateSource(newValue); |
| 357 | } |
| 358 | |
| 359 | private _getExpressionValue(expression: string, isBackConvert: boolean, changedModel: any): any { |
| 360 | let result: any = null; |
no test coverage detected