| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 | |
| 5 import 'dart:core'; | |
| 6 import 'dart:html'; | |
| 7 import 'dart:js'; | |
| 8 @MirrorsUsed(metaTargets: const [BindableAnnotation]) | |
| 9 import 'dart:mirrors'; | |
| 10 import 'package:js/js.dart'; | |
| 11 import 'package:js_util/js_util.dart'; | |
| 12 import 'package:polymer/polymer.dart'; | |
| 13 | |
| 14 const BindableAnnotation bindable = const BindableAnnotation(); | |
| 15 class BindableAnnotation { | |
| 16 const BindableAnnotation(); | |
| 17 } | |
| 18 | |
| 19 | |
| 20 ///This is a temporary bridge between Polymer Bindings and the wrapper entities. | |
| 21 class Binder<T extends HtmlElement> { | |
| 22 final Map<String, Symbol> attributes; | |
| 23 | |
| 24 const Binder(Map<String, Symbol> attributes) | |
| 25 : attributes = attributes; | |
| 26 | |
| 27 registerCallback(T element) { | |
| 28 assert(element != null); | |
| 29 setValue(element, 'bind', allowInteropCaptureThis(_callback)); | |
| 30 } | |
| 31 | |
| 32 void _callback(_this, name, value, [other]) { | |
| 33 final setter = attributes[name]; | |
| 34 if (setter == null) return; | |
| 35 Bindable bindable; | |
| 36 if (identical(1, 1.0)) { // dart2js | |
| 37 bindable = getValue(getValue(value, '__dartBindable'), 'o') as Bindable; | |
| 38 } else { // vm | |
| 39 bindable = getValue(value, '__dartBindable'); | |
| 40 } | |
| 41 var obj = reflect(_this); | |
| 42 obj.setField(setter, bindable.value); | |
| 43 bindable.open((value) { | |
| 44 obj.setField(setter, value); | |
| 45 }); | |
| 46 } | |
| 47 } | |
| OLD | NEW |