| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of template_binding; | 5 part of template_binding; |
| 6 | 6 |
| 7 /** Extensions to the [Node] API. */ | 7 /** Extensions to the [Node] API. */ |
| 8 class NodeBindExtension { | 8 class NodeBindExtension { |
| 9 final Node _node; | 9 final Node _node; |
| 10 final JsObject _js; | 10 final JsObject _js; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 | 150 |
| 151 deliver() => _js.callMethod('deliver'); | 151 deliver() => _js.callMethod('deliver'); |
| 152 } | 152 } |
| 153 | 153 |
| 154 /// Given a [bindable], create a JS object proxy for it. | 154 /// Given a [bindable], create a JS object proxy for it. |
| 155 /// This is the inverse of [jsObjectToBindable]. | 155 /// This is the inverse of [jsObjectToBindable]. |
| 156 JsObject bindableToJsObject(Bindable bindable) { | 156 JsObject bindableToJsObject(Bindable bindable) { |
| 157 if (bindable is _JsBindable) return bindable._js; | 157 if (bindable is _JsBindable) return bindable._js; |
| 158 | 158 |
| 159 var zone = Zone.current; | 159 var zone = Zone.current; |
| 160 inZone(f) => zone.bindCallback(f); | 160 inZone(f) => zone.bindCallback(f, runGuarded: false); |
| 161 inZoneUnary(f) => zone.bindUnaryCallback(f); | 161 inZoneUnary(f) => zone.bindUnaryCallback(f, runGuarded: false); |
| 162 | 162 |
| 163 return new JsObject.jsify({ | 163 return new JsObject.jsify({ |
| 164 'open': inZoneUnary( | 164 'open': inZoneUnary( |
| 165 (callback) => bindable.open((x) => callback.apply([x]))), | 165 (callback) => bindable.open((x) => callback.apply([x]))), |
| 166 'close': inZone(() => bindable.close()), | 166 'close': inZone(() => bindable.close()), |
| 167 'discardChanges': inZone(() => bindable.value), | 167 'discardChanges': inZone(() => bindable.value), |
| 168 'setValue': inZoneUnary((x) => bindable.value = x), | 168 'setValue': inZoneUnary((x) => bindable.value = x), |
| 169 // NOTE: this is not used by Node.bind, but it's used by Polymer: | 169 // NOTE: this is not used by Node.bind, but it's used by Polymer: |
| 170 // https://github.com/Polymer/polymer-dev/blob/ba2b68fe5a5721f60b5994135f327
0e63588809a/src/declaration/properties.js#L130 | 170 // https://github.com/Polymer/polymer-dev/blob/ba2b68fe5a5721f60b5994135f327
0e63588809a/src/declaration/properties.js#L130 |
| 171 // Technically this works because 'deliver' is on PathObserver and | 171 // Technically this works because 'deliver' is on PathObserver and |
| (...skipping 19 matching lines...) Expand all Loading... |
| 191 */ | 191 */ |
| 192 Node get lastNode => _lastNode; | 192 Node get lastNode => _lastNode; |
| 193 | 193 |
| 194 /** The model used to instantiate the template. */ | 194 /** The model used to instantiate the template. */ |
| 195 final model; | 195 final model; |
| 196 | 196 |
| 197 Node _firstNode, _lastNode; | 197 Node _firstNode, _lastNode; |
| 198 | 198 |
| 199 TemplateInstance(this.model); | 199 TemplateInstance(this.model); |
| 200 } | 200 } |
| OLD | NEW |