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

Delta Between Two Patch Sets: polyfill.js

Issue 29697596: Issue 6388 - Wrap inherited function properties as well (Closed)
Left Patch Set: Improved comment Created Feb. 16, 2018, 4:38 p.m.
Right Patch Set: Final tweak to the comment Created Feb. 16, 2018, 4:58 p.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
« no previous file with change/comment | « no previous file | no next file » | 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
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
Manish Jethani 2018/02/16 16:49:51 Yeah this reads much better. LGTM
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
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 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld