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

Unified Diff: pkg/polymer/lib/src/events.dart

Issue 469823002: Roll polymer to 0.3.5 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: style nit Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/polymer/lib/src/declaration.dart ('k') | pkg/polymer/lib/src/instance.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/polymer/lib/src/events.dart
diff --git a/pkg/polymer/lib/src/events.dart b/pkg/polymer/lib/src/events.dart
index ccf07861513ee26d3d4a6586cd810ce44d860f1d..881728a65c80619c0f5b6ff4d7480956229d3b5a 100644
--- a/pkg/polymer/lib/src/events.dart
+++ b/pkg/polymer/lib/src/events.dart
@@ -88,21 +88,28 @@ abstract class PolymerEventBindings {
eventType = translated != null ? translated : eventType;
return (model, node, oneTime) {
- var handler = getEventHandler(null, node, path);
- var sub = node.on[eventType].listen(handler);
+ var eventHandler =
+ Zone.current.bindUnaryCallback(getEventHandler(null, node, path));
+ // TODO(jakemac): Remove this indirection if/when JsFunction gets a
+ // simpler constructor that doesn't pass this, http://dartbug.com/20545.
+ var handler = new JsFunction.withThis((_, e) => eventHandler(e));
+ _PolymerGestures.callMethod(
+ 'addEventListener', [node, eventType, handler]);
if (oneTime) return null;
- return new _EventBindable(sub, path);
+ return new _EventBindable(path, node, eventType, handler);
};
}
}
class _EventBindable extends Bindable {
- StreamSubscription _sub;
final String _path;
+ final Node _node;
+ final String _eventType;
+ final JsFunction _handler;
- _EventBindable(this._sub, this._path);
+ _EventBindable(this._path, this._node, this._eventType, this._handler);
// TODO(rafaelw): This is really pointless work. Aside from the cost
// of these allocations, NodeBind is going to setAttribute back to its
@@ -113,10 +120,8 @@ class _EventBindable extends Bindable {
open(callback) => value;
void close() {
- if (_sub != null) {
- _sub.cancel();
- _sub = null;
- }
+ _PolymerGestures.callMethod(
+ 'removeEventListener', [_node, _eventType, _handler]);
}
}
« no previous file with comments | « pkg/polymer/lib/src/declaration.dart ('k') | pkg/polymer/lib/src/instance.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698