| 601 | } |
| 602 | |
| 603 | private updateOptions(options: { instance: WeakRef<any>; property: string }, value: any) { |
| 604 | let optionsInstance; |
| 605 | if (options && options.instance) { |
| 606 | optionsInstance = options.instance.get(); |
| 607 | } |
| 608 | |
| 609 | if (!optionsInstance) { |
| 610 | return; |
| 611 | } |
| 612 | |
| 613 | this.updating = true; |
| 614 | |
| 615 | try { |
| 616 | if (isEventOrGesture(options.property, <any>optionsInstance) && types.isFunction(value)) { |
| 617 | // Calling Observable.prototype.off() with just the event name will |
| 618 | // remove all handlers under that event name. |
| 619 | optionsInstance.off(options.property); |
| 620 | optionsInstance.on(options.property, value, optionsInstance.bindingContext); |
| 621 | } else if (optionsInstance instanceof Observable) { |
| 622 | optionsInstance.set(options.property, value); |
| 623 | } else { |
| 624 | optionsInstance[options.property] = value; |
| 625 | } |
| 626 | } catch (ex) { |
| 627 | Trace.write('Binding error while setting property ' + options.property + ' of ' + optionsInstance + ': ' + ex, Trace.categories.Binding, Trace.messageType.error); |
| 628 | } |
| 629 | |
| 630 | this.updating = false; |
| 631 | } |
| 632 | } |