WebUI: Remove legacy __proto__ usage |
||
Issue description
Using __proto__ to get/set the prototype of an object "has only been standardized in the ECMAScript 2015 specification as a legacy feature to ensure compatibility for web browsers".
We should consider bulk-converting our code base:
1. Convert `Foo.__proto__ = Bar` to `Object.setPrototypeOf(Foo, Bar)`
2. Convert non-assigning `Foo.__proto__` usage to `Object.getPrototypeOf(Foo)`
3. Convert:
function Foo() {}
Foo.prototype = {
__proto__: Bar,
more_properties: et_cetera,
};
by adding `Object.setPrototypeOf(Foo, Bar)` after the assignment.
Object.getPrototypeOf() has been standardized for a while. Landing https://chromium-review.googlesource.com/c/600852 lets us use Object.setPrototypeOf() too. Both work on iOS too.
,
Aug 4 2017
Keep in mind that __proto__ usage becomes less frequent with the usage of ES6 classses, as in
class Foo extends Bar {}
Therefore, I don't think that modifying __proto__ usage to setPrototypeOf in bulk everywhere is beneficial. Only if for other reasons an ES6 class can't be used.
,
Aug 6 2017
,
Jun 27 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/71feca28ce130057db35cf70d32a34dd9ad90325 commit 71feca28ce130057db35cf70d32a34dd9ad90325 Author: dpapad <dpapad@chromium.org> Date: Wed Jun 27 02:45:12 2018 WebUI cleanup: Use ES6 classes in a few more places. Bug: 752636 Cq-Include-Trybots: luci.chromium.try:closure_compilation Change-Id: I60e551d903fa275b48eab0c2bf33c6a65dd080c3 Reviewed-on: https://chromium-review.googlesource.com/1114059 Reviewed-by: Hector Carmona <hcarmona@chromium.org> Commit-Queue: Demetrios Papadopoulos <dpapad@chromium.org> Cr-Commit-Position: refs/heads/master@{#570644} [modify] https://crrev.com/71feca28ce130057db35cf70d32a34dd9ad90325/chrome/browser/resources/md_extensions/drag_and_drop_handler.js [modify] https://crrev.com/71feca28ce130057db35cf70d32a34dd9ad90325/chrome/browser/resources/md_history/browser_service.js [modify] https://crrev.com/71feca28ce130057db35cf70d32a34dd9ad90325/chrome/browser/resources/md_history/history_item.js [modify] https://crrev.com/71feca28ce130057db35cf70d32a34dd9ad90325/chrome/browser/resources/md_user_manager/BUILD.gn [modify] https://crrev.com/71feca28ce130057db35cf70d32a34dd9ad90325/chrome/browser/resources/md_user_manager/profile_browser_proxy.js [modify] https://crrev.com/71feca28ce130057db35cf70d32a34dd9ad90325/chrome/browser/resources/settings/animation/animation.js [modify] https://crrev.com/71feca28ce130057db35cf70d32a34dd9ad90325/chrome/browser/resources/settings/focus_row_behavior.js [modify] https://crrev.com/71feca28ce130057db35cf70d32a34dd9ad90325/chrome/browser/resources/settings/languages_page/BUILD.gn [modify] https://crrev.com/71feca28ce130057db35cf70d32a34dd9ad90325/chrome/browser/resources/settings/languages_page/languages_types.js |
||
►
Sign in to add a comment |
||
Comment 1 by michae...@chromium.org
, Aug 4 2017