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

Side by Side Diff: ui/webui/resources/cr_elements/v0_8/cr_events/cr_events.js

Issue 1150173003: Fix some JS style nits. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 5 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
« no previous file with comments | « ui/webui/resources/cr_elements/cr_events/cr_events.js ('k') | ui/webui/resources/js/cr.js » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * `cr-events` provides helpers for handling events in Chrome Polymer elements. 7 * `cr-events` provides helpers for handling events in Chrome Polymer elements.
8 * 8 *
9 * Example: 9 * Example:
10 * 10 *
11 * <cr-events id="events"></cr-events> 11 * <cr-events id="events"></cr-events>
12 * 12 *
13 * Usage: 13 * Usage:
14 * 14 *
15 * this.$.events.forward(this.$.element, ['change']); 15 * this.$.events.forward(this.$.element, ['change']);
16 * 16 *
17 * @element cr-events 17 * @element cr-events
18 */ 18 */
19 Polymer({ 19 Polymer({
20 is: 'cr-events', 20 is: 'cr-events',
21 21
22 /** 22 /**
23 * Sets up an element to forward events across the shadow boundary, for events 23 * Sets up an element to forward events across the shadow boundary, for events
24 * which normally stop at the root node (see http://goo.gl/WGMO9x). 24 * which normally stop at the root node (see http://goo.gl/WGMO9x).
25 * @param {!HTMLElement} element The element to forward events from. 25 * @param {!HTMLElement} element The element to forward events from.
26 * @param {!Array.<string>} events The events to forward. 26 * @param {!Array<string>} events The events to forward.
27 */ 27 */
28 forward: function(element, events) { 28 forward: function(element, events) {
29 for (var i = 0; i < events.length; i++) 29 for (var i = 0; i < events.length; i++)
30 element.addEventListener(events[i], this.forwardEvent_); 30 element.addEventListener(events[i], this.forwardEvent_);
31 }, 31 },
32 32
33 /** 33 /**
34 * Forwards events that don't automatically cross the shadow boundary 34 * Forwards events that don't automatically cross the shadow boundary
35 * if the event should bubble. 35 * if the event should bubble.
36 * @param {!Event} e The event to forward. 36 * @param {!Event} e The event to forward.
37 * @param {*} detail Data passed when initializing the event. 37 * @param {*} detail Data passed when initializing the event.
38 * @param {Node=} opt_sender Node that declared the handler. 38 * @param {Node=} opt_sender Node that declared the handler.
39 * @private 39 * @private
40 */ 40 */
41 forwardEvent_: function(e, detail, opt_sender) { 41 forwardEvent_: function(e, detail, opt_sender) {
42 if (!e.bubbles) 42 if (!e.bubbles)
43 return; 43 return;
44 44
45 var node = e.path[e.path.length - 1]; 45 var node = e.path[e.path.length - 1];
46 if (node instanceof ShadowRoot) { 46 if (node instanceof ShadowRoot) {
47 // Forward the event to the shadow host. 47 // Forward the event to the shadow host.
48 e.stopPropagation(); 48 e.stopPropagation();
49 node.host.fire(e.type, detail, node.host, true, e.cancelable); 49 node.host.fire(e.type, detail, node.host, true, e.cancelable);
50 } 50 }
51 }, 51 },
52 }); 52 });
OLDNEW
« no previous file with comments | « ui/webui/resources/cr_elements/cr_events/cr_events.js ('k') | ui/webui/resources/js/cr.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698