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: Created Feb. 28, 2018, 3:08 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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 /* global defineNamespace */ 18 /* global defineNamespace */
19 19
20 "use strict"; 20 "use strict";
21 21
22 const internal = Symbol(); 22 const internal = Symbol();
Manish Jethani 2018/02/28 15:23:27 The symbol is defined in ext/common.js since it is
23 23
24 { 24 {
25 window.ext = {}; 25 window.ext = {};
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) =>
Manish Jethani 2018/02/28 15:23:27 EventTarget.prototype._dispatch is now ext[interna
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