| 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 polymer; | 5 part of polymer; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Use this annotation to publish a field as an attribute. For example: | 8 * Use this annotation to publish a field as an attribute. For example: |
| 9 * | 9 * |
| 10 * class MyPlaybackElement extends PolymerElement { | 10 * class MyPlaybackElement extends PolymerElement { |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 // provide an event-binding callback. | 756 // provide an event-binding callback. |
| 757 return (model, node) { | 757 return (model, node) { |
| 758 if (_eventsLog.isLoggable(Level.FINE)) { | 758 if (_eventsLog.isLoggable(Level.FINE)) { |
| 759 _eventsLog.fine('event: [$node].$name => [$model].$path())'); | 759 _eventsLog.fine('event: [$node].$name => [$model].$path())'); |
| 760 } | 760 } |
| 761 var eventName = _removeEventPrefix(name); | 761 var eventName = _removeEventPrefix(name); |
| 762 // TODO(sigmund): polymer.js dropped event translations. reconcile? | 762 // TODO(sigmund): polymer.js dropped event translations. reconcile? |
| 763 var translated = _eventTranslations[eventName]; | 763 var translated = _eventTranslations[eventName]; |
| 764 eventName = translated != null ? translated : eventName; | 764 eventName = translated != null ? translated : eventName; |
| 765 | 765 |
| 766 // TODO(jmesserly): returning a StreamSubscription as the model is quite | 766 // TODO(jmesserly): we need a place to unregister this. See: |
| 767 // strange. package:template_binding doesn't have any cleanup logic to | 767 // https://code.google.com/p/dart/issues/detail?id=15574 |
| 768 // handle that. | 768 node.on[eventName].listen((event) { |
| 769 return node.on[eventName].listen((event) { | |
| 770 var ctrlr = _findController(node); | 769 var ctrlr = _findController(node); |
| 771 if (ctrlr is! Polymer) return; | 770 if (ctrlr is! Polymer) return; |
| 772 var obj = ctrlr; | 771 var obj = ctrlr; |
| 773 var method = path; | 772 var method = path; |
| 774 if (path[0] == '@') { | 773 if (path[0] == '@') { |
| 775 obj = model; | 774 obj = model; |
| 776 method = new PathObserver(model, path.substring(1)).value; | 775 method = new PathObserver(model, path.substring(1)).value; |
| 777 } | 776 } |
| 778 var detail = event is CustomEvent ? | 777 var detail = event is CustomEvent ? |
| 779 (event as CustomEvent).detail : null; | 778 (event as CustomEvent).detail : null; |
| 780 ctrlr.dispatchMethod(obj, method, [event, detail, node]); | 779 ctrlr.dispatchMethod(obj, method, [event, detail, node]); |
| 781 }); | 780 }); |
| 781 |
| 782 // TODO(jmesserly): this return value is bogus. Returning null here causes |
| 783 // the wrong thing to happen in template_binding. |
| 784 return new ObservableBox(); |
| 782 }; | 785 }; |
| 783 } | 786 } |
| 784 | 787 |
| 785 // TODO(jmesserly): this won't find the correct host unless the ShadowRoot | 788 // TODO(jmesserly): this won't find the correct host unless the ShadowRoot |
| 786 // was created on a PolymerElement. | 789 // was created on a PolymerElement. |
| 787 static Polymer _findController(Node node) { | 790 static Polymer _findController(Node node) { |
| 788 while (node.parentNode != null) { | 791 while (node.parentNode != null) { |
| 789 node = node.parentNode; | 792 node = node.parentNode; |
| 790 } | 793 } |
| 791 return _shadowHost[node]; | 794 return _shadowHost[node]; |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1088 | 1091 |
| 1089 class _PropertyValue { | 1092 class _PropertyValue { |
| 1090 Object oldValue, newValue; | 1093 Object oldValue, newValue; |
| 1091 _PropertyValue(this.oldValue); | 1094 _PropertyValue(this.oldValue); |
| 1092 } | 1095 } |
| 1093 | 1096 |
| 1094 class _PolymerExpressionsWithEventDelegate extends PolymerExpressions { | 1097 class _PolymerExpressionsWithEventDelegate extends PolymerExpressions { |
| 1095 prepareBinding(String path, name, node) => | 1098 prepareBinding(String path, name, node) => |
| 1096 Polymer.prepareBinding(path, name, node, super.prepareBinding); | 1099 Polymer.prepareBinding(path, name, node, super.prepareBinding); |
| 1097 } | 1100 } |
| OLD | NEW |