Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(472)

Side by Side Diff: pkg/polymer/lib/src/events.dart

Issue 317013007: Detect and wrap JS-CustomEvents if applicable. Include created_watcher and (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 /// Code from declaration/events.js 5 /// Code from declaration/events.js
6 part of polymer; 6 part of polymer;
7 7
8 /// An extension of [polymer_expressions.PolymerExpressions] that adds support 8 /// An extension of [polymer_expressions.PolymerExpressions] that adds support
9 /// for binding events using `on-eventName` using [PolymerEventBindings]. 9 /// for binding events using `on-eventName` using [PolymerEventBindings].
10 // TODO(jmesserly): the JS layering is a bit odd, with polymer-dev implementing 10 // TODO(jmesserly): the JS layering is a bit odd, with polymer-dev implementing
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 } 50 }
51 return node is ShadowRoot ? node.host : null; 51 return node is ShadowRoot ? node.host : null;
52 } 52 }
53 53
54 EventListener getEventHandler(controller, target, String method) => (e) { 54 EventListener getEventHandler(controller, target, String method) => (e) {
55 if (controller == null || controller is! Polymer) { 55 if (controller == null || controller is! Polymer) {
56 controller = findController(target); 56 controller = findController(target);
57 } 57 }
58 58
59 if (controller is Polymer) { 59 if (controller is Polymer) {
60 var args = [e, e.detail, e.currentTarget]; 60 var detail = null;
61 if (e is CustomEvent) {
Siggi Cherem (dart-lang) 2014/06/06 22:42:24 this part was a regression, I think (we used to ch
Jennifer Messerly 2014/06/09 16:54:37 ah, right... it should've been: var detail =
Siggi Cherem (dart-lang) 2014/06/10 01:39:34 I think that's OK. The current test I'm adding sho
62 detail = e.detail;
63 // Dart note: to improve interop with polymer.js elements, we try to
64 // proxy any js detail objects.
65 if (detail == null) {
justinfagnani 2014/06/06 23:37:05 I'm confused by this, are the Dart detail and the
Jennifer Messerly 2014/06/09 16:54:37 for some reason, CustomEvent is a bit wacky in dar
Siggi Cherem (dart-lang) 2014/06/10 01:39:34 Seems like the scenario I hit when wrapping a core
66 detail = new JsObject.fromBrowserObject(e)['detail'];
67 }
68 }
69 var args = [e, detail, e.currentTarget];
61 controller.dispatchMethod(controller, method, args); 70 controller.dispatchMethod(controller, method, args);
62 } else { 71 } else {
63 throw new StateError('controller $controller is not a ' 72 throw new StateError('controller $controller is not a '
64 'Dart polymer-element.'); 73 'Dart polymer-element.');
65 } 74 }
66 }; 75 };
67 76
68 prepareEventBinding(String path, String name, Node node) { 77 prepareEventBinding(String path, String name, Node node) {
69 if (!_hasEventPrefix(name)) return null; 78 if (!_hasEventPrefix(name)) return null;
70 79
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 return map; 149 return map;
141 }(); 150 }();
142 151
143 // Dart note: we need this function because we have additional renames JS does 152 // Dart note: we need this function because we have additional renames JS does
144 // not have. The JS renames are simply case differences, whereas we have ones 153 // not have. The JS renames are simply case differences, whereas we have ones
145 // like doubleclick -> dblclick and stripping the webkit prefix. 154 // like doubleclick -> dblclick and stripping the webkit prefix.
146 String _eventNameFromType(String eventType) { 155 String _eventNameFromType(String eventType) {
147 final result = _reverseEventTranslations[eventType]; 156 final result = _reverseEventTranslations[eventType];
148 return result != null ? result : eventType; 157 return result != null ? result : eventType;
149 } 158 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698