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

Side by Side Diff: lib/event.dart

Issue 22962005: Merge pull request #581 from kevmoo/polymer (Closed) Base URL: https://github.com/dart-lang/web-ui.git@polymer
Patch Set: Created 7 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 unified diff | Download patch
« no previous file with comments | « lib/dwc.dart ('k') | lib/observe.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library polymer.event;
6
7 import 'dart:html';
8 import 'package:custom_element/custom_element.dart';
9
10 /**
11 * *Warning*: this is an implementation helper and should not be used in your
12 * code. This method will be replaced in favor of calling to the handler
13 * via mirrors.
14 *
15 * Register an event handler.
16 */
17 void registerEventHandler(String query, void registerEvent(Node node)) {
18 if (_eventHandlers == null) {
19 _eventHandlers = {};
20 CustomElement.templateCreated.add(_hookEvents);
21 }
22 if (_eventHandlers.containsKey(query)) {
23 throw new ArgumentError('duplicate event handler selector $query');
24 }
25 _eventHandlers[query] = registerEvent;
26 }
27
28 void _hookEvents(DocumentFragment fragment) {
29 _eventHandlers.forEach((query, hookEvent) {
30 for (var node in fragment.queryAll(query)) {
31 hookEvent(node);
32 }
33 });
34 }
35
36 Map<String, Function> _eventHandlers;
OLDNEW
« no previous file with comments | « lib/dwc.dart ('k') | lib/observe.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698