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: Use method shorthand Created Feb. 16, 2018, 4:35 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 object = object[node]; 71 object = object[node];
72 72
73 if (!object) 73 if (!object)
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 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 presereved, 83 // inherited its other attributes (e.g. enumerable) are preserved,
84 // except accessor properties since we're specifying a value. 84 // except for accessor attributes (e.g. get and set) which are discarded
85 // since we're specifying a value.
85 Object.defineProperty(object, name, { 86 Object.defineProperty(object, name, {
86 value(...args) 87 value(...args)
87 { 88 {
88 let callStack = new Error().stack; 89 let callStack = new Error().stack;
89 90
90 if (typeof args[args.length - 1] == "function") 91 if (typeof args[args.length - 1] == "function")
91 return func.apply(object, args); 92 return func.apply(object, args);
92 93
93 // 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
94 // 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
227 228
228 // Workaround since HTMLCollection, NodeList, StyleSheetList, and CSSRuleList 229 // Workaround since HTMLCollection, NodeList, StyleSheetList, and CSSRuleList
229 // didn't have iterator support before Chrome 51. 230 // didn't have iterator support before Chrome 51.
230 // https://bugs.chromium.org/p/chromium/issues/detail?id=401699 231 // https://bugs.chromium.org/p/chromium/issues/detail?id=401699
231 for (let object of [HTMLCollection, NodeList, StyleSheetList, CSSRuleList]) 232 for (let object of [HTMLCollection, NodeList, StyleSheetList, CSSRuleList])
232 { 233 {
233 if (!(Symbol.iterator in object.prototype)) 234 if (!(Symbol.iterator in object.prototype))
234 object.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator]; 235 object.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator];
235 } 236 }
236 } 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