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

Side by Side Diff: third_party/polymer/components-chromium/core-signals/core-signals-extracted.js

Issue 592593002: Inline scripts were extracted from Polymer elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/echo ""/echo/ Created 6 years, 2 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
OLDNEW
(Empty)
1
2 (function(){
3
4 Polymer('core-signals',{
5 attached: function() {
6 signals.push(this);
7 },
8 removed: function() {
9 var i = signals.indexOf(this);
10 if (i >= 0) {
11 signals.splice(i, 1);
12 }
13 }
14 });
15
16 // private shared database
17 var signals = [];
18
19 // signal dispatcher
20 function notify(name, data) {
21 // convert generic-signal event to named-signal event
22 var signal = new CustomEvent('core-signal-' + name, {
23 // if signals bubble, it's easy to get confusing duplicates
24 // (1) listen on a container on behalf of local child
25 // (2) some deep child ignores the event and it bubbles
26 // up to said container
27 // (3) local child event bubbles up to container
28 // also, for performance, we avoid signals flying up the
29 // tree from all over the place
30 bubbles: false,
31 detail: data
32 });
33 // dispatch named-signal to all 'signals' instances,
34 // only interested listeners will react
35 signals.forEach(function(s) {
36 s.dispatchEvent(signal);
37 });
38 }
39
40 // signal listener at document
41 document.addEventListener('core-signal', function(e) {
42 notify(e.detail.name, e.detail.data);
43 });
44
45 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698