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

Side by Side Diff: lib/event.dart

Issue 20863002: Introduce boot.js: this finally makes it possible to load and run Todomvc (Closed) Base URL: git@github.com:dart-lang/web-ui.git@master
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/custom_element.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
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 library polymer.event; 5 library polymer.event;
6 6
7 import 'dart:html'; 7 import 'dart:html';
8 import 'custom_element.dart'; 8 import 'package:custom_element/custom_element.dart';
9 9
10 /** 10 /**
11 * *Warning*: this is an implementation helper and should not be used in your 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 12 * code. This method will be replaced in favor of calling to the handler
13 * via mirrors. 13 * via mirrors.
14 * 14 *
15 * Register an event handler. 15 * Register an event handler.
16 */ 16 */
17 void registerEventHandler(String query, void registerEvent(Node node)) { 17 void registerEventHandler(String query, void registerEvent(Node node)) {
18 if (_eventHandlers == null) { 18 if (_eventHandlers == null) {
19 _eventHandlers = {}; 19 _eventHandlers = {};
20 CustomElement.templateCreated.add(_hookEvents); 20 CustomElement.templateCreated.add(_hookEvents);
21 } 21 }
22 if (_eventHandlers.containsKey(query)) { 22 if (_eventHandlers.containsKey(query)) {
23 throw new ArgumentError('duplicate event handler selector $query'); 23 throw new ArgumentError('duplicate event handler selector $query');
24 } 24 }
25 _eventHandlers[query] = registerEvent; 25 _eventHandlers[query] = registerEvent;
26 } 26 }
27 27
28 void _hookEvents(DocumentFragment fragment) { 28 void _hookEvents(DocumentFragment fragment) {
29 _eventHandlers.forEach((query, hookEvent) { 29 _eventHandlers.forEach((query, hookEvent) {
30 for (var node in fragment.queryAll(query)) { 30 for (var node in fragment.queryAll(query)) {
31 hookEvent(node); 31 hookEvent(node);
32 } 32 }
33 }); 33 });
34 } 34 }
35 35
36 Map<String, Function> _eventHandlers; 36 Map<String, Function> _eventHandlers;
OLDNEW
« no previous file with comments | « lib/custom_element.dart ('k') | lib/observe.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698