Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: ext/common.js

Issue 29711592: Issue 6424 - Use internal symbol in ext namespace (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Left Patch Set: Support internal methods Created Feb. 28, 2018, 4:32 p.m.
Right Patch Set: Switch to internal methods everywhere Created March 1, 2018, 11:58 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« ext/background.js ('K') | « ext/background.js ('k') | ext/content.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 15 matching lines...) Expand all
26 26
27 defineNamespace(ext, internal); 27 defineNamespace(ext, internal);
28 28
29 let EventTarget = ext[internal].EventTarget = function() 29 let EventTarget = ext[internal].EventTarget = function()
30 { 30 {
31 defineNamespace(this, internal); 31 defineNamespace(this, internal);
32 32
33 this[internal].listeners = new Set(); 33 this[internal].listeners = new Set();
34 }; 34 };
35 EventTarget.prototype = { 35 EventTarget.prototype = {
36 [internal]: {
37 dispatch(...args)
38 {
39 return [...this[internal].listeners].map(listener => listener(...args));
40 }
41 },
36 addListener(listener) 42 addListener(listener)
37 { 43 {
38 this[internal].listeners.add(listener); 44 this[internal].listeners.add(listener);
39 }, 45 },
40 removeListener(listener) 46 removeListener(listener)
41 { 47 {
42 this[internal].listeners.delete(listener); 48 this[internal].listeners.delete(listener);
43 } 49 }
44 }; 50 };
45 51
46 ext[internal].dispatchEvent = (eventTarget, ...args) =>
47 [...eventTarget[internal].listeners].map(
48 listener => listener(...args)
49 );
50
51 52
52 /* Message passing */ 53 /* Message passing */
53 54
54 ext.onMessage = new ext[internal].EventTarget(); 55 ext.onMessage = new ext[internal].EventTarget();
55 } 56 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld