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

Side by Side Diff: polyfill.js

Issue 29589637: Issue 4579 - Do not wrap non-existent APIs (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Created Oct. 26, 2017, 3:40 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 for (let node of path) 61 for (let node of path)
62 { 62 {
63 object = object[node]; 63 object = object[node];
64 64
65 if (!object) 65 if (!object)
66 return; 66 return;
67 } 67 }
68 68
69 let func = object[name]; 69 let func = object[name];
70 if (!func)
71 return;
72
70 object[name] = function(...args) 73 object[name] = function(...args)
71 { 74 {
72 let callStack = new Error().stack; 75 let callStack = new Error().stack;
73 76
74 if (typeof args[args.length - 1] == "function") 77 if (typeof args[args.length - 1] == "function")
75 return func.apply(object, args); 78 return func.apply(object, args);
76 79
77 // If the last argument is undefined, we drop it from the list assuming 80 // If the last argument is undefined, we drop it from the list assuming
78 // it stands for the optional callback. We must do this, because we have 81 // it stands for the optional callback. We must do this, because we have
79 // to replace it with our own callback. If we simply append our own 82 // to replace it with our own callback. If we simply append our own
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 140
138 // Workaround since HTMLCollection, NodeList, StyleSheetList, and CSSRuleList 141 // Workaround since HTMLCollection, NodeList, StyleSheetList, and CSSRuleList
139 // didn't have iterator support before Chrome 51. 142 // didn't have iterator support before Chrome 51.
140 // https://bugs.chromium.org/p/chromium/issues/detail?id=401699 143 // https://bugs.chromium.org/p/chromium/issues/detail?id=401699
141 for (let object of [HTMLCollection, NodeList, StyleSheetList, CSSRuleList]) 144 for (let object of [HTMLCollection, NodeList, StyleSheetList, CSSRuleList])
142 { 145 {
143 if (!(Symbol.iterator in object.prototype)) 146 if (!(Symbol.iterator in object.prototype))
144 object.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator]; 147 object.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator];
145 } 148 }
146 } 149 }
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