LEFT | RIGHT |
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 return; | 74 return; |
75 } | 75 } |
76 | 76 |
77 let func = object[name]; | 77 let func = object[name]; |
78 if (!func) | 78 if (!func) |
79 return; | 79 return; |
80 | 80 |
81 // If the property is not writable assigning it will fail, so we use | 81 // If the property is not writable assigning it will fail, so we use |
82 // Object.defineProperty here instead. Assuming the property isn't | 82 // Object.defineProperty here instead. Assuming the property isn't |
83 // inherited its other attributes (e.g. enumerable) are preserved, | 83 // inherited its other attributes (e.g. enumerable) are preserved, |
84 // except accessor property attributes (e.g. get and set) since | 84 // except for accessor attributes (e.g. get and set) which are discarded |
85 // we're specifying a value. | 85 // since we're specifying a value. |
86 Object.defineProperty(object, name, { | 86 Object.defineProperty(object, name, { |
87 value(...args) | 87 value(...args) |
88 { | 88 { |
89 let callStack = new Error().stack; | 89 let callStack = new Error().stack; |
90 | 90 |
91 if (typeof args[args.length - 1] == "function") | 91 if (typeof args[args.length - 1] == "function") |
92 return func.apply(object, args); | 92 return func.apply(object, args); |
93 | 93 |
94 // If the last argument is undefined, we drop it from the list assuming | 94 // If the last argument is undefined, we drop it from the list assuming |
95 // it stands for the optional callback. We must do this, because we have | 95 // it stands for the optional callback. We must do this, because we have |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 | 228 |
229 // Workaround since HTMLCollection, NodeList, StyleSheetList, and CSSRuleList | 229 // Workaround since HTMLCollection, NodeList, StyleSheetList, and CSSRuleList |
230 // didn't have iterator support before Chrome 51. | 230 // didn't have iterator support before Chrome 51. |
231 // https://bugs.chromium.org/p/chromium/issues/detail?id=401699 | 231 // https://bugs.chromium.org/p/chromium/issues/detail?id=401699 |
232 for (let object of [HTMLCollection, NodeList, StyleSheetList, CSSRuleList]) | 232 for (let object of [HTMLCollection, NodeList, StyleSheetList, CSSRuleList]) |
233 { | 233 { |
234 if (!(Symbol.iterator in object.prototype)) | 234 if (!(Symbol.iterator in object.prototype)) |
235 object.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator]; | 235 object.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator]; |
236 } | 236 } |
237 } | 237 } |
LEFT | RIGHT |