New issue
Advanced search Search tips

Issue 752636 link

Starred by 1 user

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

WebUI: Remove legacy __proto__ usage

Project Member Reported by michae...@chromium.org, Aug 4 2017

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.
 
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.
Labels: -Pri-2 Pri-3
Project Member

Comment 4 by bugdroid1@chromium.org, 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