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

Side by Side Diff: chrome/ext/content.js

Issue 29371763: Issue 4795 - Use modern JavaScript syntax (Closed)
Patch Set: Workaround limiation with iterating element collections in older versions of Chrome Created Jan. 16, 2017, 8:46 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) 1 "use strict";
2
3 chrome.runtime.onMessage.addListener((message, sender, sendResponse) =>
2 { 4 {
3 return ext.onMessage._dispatch(message, {}, sendResponse).indexOf(true) != -1; 5 return ext.onMessage._dispatch(message, {}, sendResponse).indexOf(true) != -1;
4 }); 6 });
5 7
6 ext.onExtensionUnloaded = (function() 8 ext.onExtensionUnloaded = (() =>
7 { 9 {
8 var port = null; 10 let port = null;
9 11
10 return { 12 return {
11 addListener: function(listener) 13 addListener(listener)
12 { 14 {
13 if (!port) 15 if (!port)
14 port = chrome.runtime.connect(); 16 port = chrome.runtime.connect();
15 17
16 // When the extension is reloaded, disabled or uninstalled the 18 // When the extension is reloaded, disabled or uninstalled the
17 // background page dies and automatically disconnects all ports 19 // background page dies and automatically disconnects all ports
18 port.onDisconnect.addListener(listener); 20 port.onDisconnect.addListener(listener);
19 }, 21 },
20 removeListener: function(listener) 22 removeListener(listener)
21 { 23 {
22 if (port) 24 if (port)
23 { 25 {
24 port.onDisconnect.removeListener(listener); 26 port.onDisconnect.removeListener(listener);
25 27
26 if (!port.onDisconnect.hasListeners()) 28 if (!port.onDisconnect.hasListeners())
27 { 29 {
28 port.disconnect(); 30 port.disconnect();
29 port = null; 31 port = null;
30 } 32 }
31 } 33 }
32 } 34 }
33 }; 35 };
34 })(); 36 })();
OLDNEW
« no previous file with comments | « chrome/ext/common.js ('k') | chrome/ext/devtools.js » ('j') | lib/notificationHelper.js » ('J')

Powered by Google App Engine
This is Rietveld