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

Unified Diff: ui/webui/resources/cr_elements/cr_events/cr-events.js

Issue 902053003: Add cr-toggle-button to Chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more renames; add to chrome://md-settings Created 5 years, 10 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
Index: ui/webui/resources/cr_elements/cr_events/cr-events.js
diff --git a/ui/webui/resources/cr_elements/cr_events/cr-events.js b/ui/webui/resources/cr_elements/cr_events/cr-events.js
new file mode 100644
index 0000000000000000000000000000000000000000..ce54662673f647042dc0e785f55a26e8c8f24471
--- /dev/null
+++ b/ui/webui/resources/cr_elements/cr_events/cr-events.js
@@ -0,0 +1,34 @@
+/* Copyright 2015 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file. */
+
+/**
+ * @fileoverview
+ * `cr-events` provides helpers for handling events in Chrome Polymer elements.
+ *
+ * Example:
+ *
+ * <cr-events></cr-events>
+ *
+ * @element cr-events
+ */
+Polymer({
+ /**
+ * Forwards events that don't automatically cross the shadow boundary
+ * if the event should bubble.
+ * @param {!Event} e The event to forward.
+ * @param {*} detail Data passed when initializing the event.
+ * @param {Node=} sender Node that declared the handler.
+ */
+ forwardEvent: function(e, detail, sender) {
+ if (!e.bubbles)
+ return;
+
+ var node = e.path[e.path.length - 1];
+ if (node instanceof ShadowRoot) {
+ // Forward the event to the shadow host.
+ e.stopPropagation();
+ node.host.fire(e.type, detail, node.host, true, e.cancelable);
+ }
+ },
+});

Powered by Google App Engine
This is Rietveld 408576698