| 893 | private bindingContextBoundToParentBindingContextChanged: boolean; |
| 894 | |
| 895 | public bind(options: BindingOptions, source: Object = defaultBindingSource): void { |
| 896 | const targetProperty = options.targetProperty; |
| 897 | this.unbind(targetProperty); |
| 898 | |
| 899 | if (!this.bindings) { |
| 900 | this.bindings = new Map<string, Binding>(); |
| 901 | } |
| 902 | |
| 903 | const binding = new Binding(this, options); |
| 904 | this.bindings.set(targetProperty, binding); |
| 905 | |
| 906 | let bindingSource = source; |
| 907 | if (bindingSource === defaultBindingSource) { |
| 908 | bindingSource = this.bindingContext; |
| 909 | binding.sourceIsBindingContext = true; |
| 910 | if (targetProperty === 'bindingContext') { |
| 911 | this.bindingContextBoundToParentBindingContextChanged = true; |
| 912 | const parent = this.parent; |
| 913 | if (parent) { |
| 914 | parent.on('bindingContextChange', this.bindingContextChanged, this); |
| 915 | } else { |
| 916 | this.shouldAddHandlerToParentBindingContextChanged = true; |
| 917 | } |
| 918 | } |
| 919 | } |
| 920 | |
| 921 | binding.bind(bindingSource); |
| 922 | } |
| 923 | |
| 924 | public unbind(property: string): void { |
| 925 | const bindings = this.bindings; |