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

Side by Side Diff: ext/common.js

Issue 29557738: Issue 5773 - Polyfill iterator for CSSRuleList and StyleSheetList (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Created Sept. 27, 2017, 10:58 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 { 44 {
45 let results = []; 45 let results = [];
46 46
47 for (let listener of this._listeners) 47 for (let listener of this._listeners)
48 results.push(listener(...args)); 48 results.push(listener(...args));
49 49
50 return results; 50 return results;
51 } 51 }
52 }; 52 };
53 53
54 // Workaround since HTMLCollection and NodeList didn't have iterator support 54 // Workaround since HTMLCollection, NodeList, StyleSheet and
55 // before Chrome 51. 55 // CSSRuleList didn't have iterator support before Chrome 51.
56 // https://bugs.chromium.org/p/chromium/issues/detail?id=401699 56 // https://bugs.chromium.org/p/chromium/issues/detail?id=401699
57 let arrayIterator = Array.prototype[Symbol.iterator]; 57 let arrayIterator = Array.prototype[Symbol.iterator];
58 if (!(Symbol.iterator in HTMLCollection.prototype)) 58 if (!(Symbol.iterator in HTMLCollection.prototype))
59 HTMLCollection.prototype[Symbol.iterator] = arrayIterator; 59 HTMLCollection.prototype[Symbol.iterator] = arrayIterator;
60 if (!(Symbol.iterator in NodeList.prototype)) 60 if (!(Symbol.iterator in NodeList.prototype))
61 NodeList.prototype[Symbol.iterator] = arrayIterator; 61 NodeList.prototype[Symbol.iterator] = arrayIterator;
62 if (!(Symbol.iterator in StyleSheetList.prototype))
63 StyleSheetList.prototype[Symbol.iterator] = arrayIterator;
64 if (!(Symbol.iterator in CSSRuleList.prototype))
65 CSSRuleList.prototype[Symbol.iterator] = arrayIterator;
62 66
63 /* Message passing */ 67 /* Message passing */
64 68
65 ext.onMessage = new ext._EventTarget(); 69 ext.onMessage = new ext._EventTarget();
66 70
67 71
68 /* Background page */ 72 /* Background page */
69 73
70 ext.backgroundPage = { 74 ext.backgroundPage = {
71 sendMessage: chrome.runtime.sendMessage, 75 sendMessage: chrome.runtime.sendMessage,
72 getWindow() 76 getWindow()
73 { 77 {
74 return chrome.extension.getBackgroundPage(); 78 return chrome.extension.getBackgroundPage();
75 } 79 }
76 }; 80 };
77 81
78 82
79 /* Utils */ 83 /* Utils */
80 84
81 ext.getURL = chrome.extension.getURL; 85 ext.getURL = chrome.extension.getURL;
82 ext.i18n = chrome.i18n; 86 ext.i18n = chrome.i18n;
83 }()); 87 }());
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld