OLD | NEW |
(Empty) | |
| 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 |
| 3 * found in the LICENSE file. */ |
| 4 |
| 5 /** |
| 6 * @fileoverview |
| 7 * `cr-events` provides helpers for handling events in Chrome Polymer elements. |
| 8 * |
| 9 * Example: |
| 10 * |
| 11 * <cr-events></cr-events> |
| 12 * |
| 13 * @element cr-events |
| 14 */ |
| 15 Polymer({ |
| 16 /** |
| 17 * Forwards events that don't automatically cross the shadow boundary |
| 18 * if the event should bubble. |
| 19 * @param {!Event} e The event to forward. |
| 20 * @param {*} detail Data passed when initializing the event. |
| 21 * @param {Node=} sender Node that declared the handler. |
| 22 */ |
| 23 forwardEvent: function(e, detail, sender) { |
| 24 if (!e.bubbles) |
| 25 return; |
| 26 |
| 27 var node = e.path[e.path.length - 1]; |
| 28 if (node instanceof ShadowRoot) { |
| 29 // Forward the event to the shadow host. |
| 30 e.stopPropagation(); |
| 31 node.host.fire(e.type, detail, node.host, true, e.cancelable); |
| 32 } |
| 33 }, |
| 34 }); |
OLD | NEW |