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

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

Issue 482763002: Revert "Roll polymer to 0.3.5" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 881728a65c80619c0f5b6ff4d7480956229d3b5a..ccf07861513ee26d3d4a6586cd810ce44d860f1d 100644
--- a/pkg/polymer/lib/src/events.dart
+++ b/pkg/polymer/lib/src/events.dart
@@ -88,28 +88,21 @@ abstract class PolymerEventBindings {
eventType = translated != null ? translated : eventType;
return (model, node, oneTime) {
- 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]);
+ var handler = getEventHandler(null, node, path);
+ var sub = node.on[eventType].listen(handler);
if (oneTime) return null;
- return new _EventBindable(path, node, eventType, handler);
+ return new _EventBindable(sub, path);
};
}
}
class _EventBindable extends Bindable {
+ StreamSubscription _sub;
final String _path;
- final Node _node;
- final String _eventType;
- final JsFunction _handler;
- _EventBindable(this._path, this._node, this._eventType, this._handler);
+ _EventBindable(this._sub, this._path);
// TODO(rafaelw): This is really pointless work. Aside from the cost
// of these allocations, NodeBind is going to setAttribute back to its
@@ -120,8 +113,10 @@ class _EventBindable extends Bindable {
open(callback) => value;
void close() {
- _PolymerGestures.callMethod(
- 'removeEventListener', [_node, _eventType, _handler]);
+ if (_sub != null) {
+ _sub.cancel();
+ _sub = null;
+ }
}
}
« 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