Opened on 06/09/2014 at 11:04:02 AM

Closed on 06/27/2014 at 05:17:49 PM

Last modified on 05/20/2015 at 02:22:39 PM

#656 closed change (fixed)

Replace __proto__ with Object.create

Reported by: tschuster Assignee: tschuster
Priority: Unknown Milestone: Adblock-Plus-2.6.4-for-Firefox
Module: Adblock-Plus-for-Firefox Keywords:
Cc: trev, sebastian Blocked By:
Blocking: #427 Platform: Firefox
Ready: no Confidential: no
Tester: Verified working: no
Review URL(s):

http://codereview.adblockplus.org/5636077285015552/

Description

I am not yet 100% sure if we should really do this. Especially because code like this becomes ugly:

Foo = function () {}
Foo.prototype = {
  __proto__: Bar.prototype,
  foo: 1
}
/* vs. */
Foo = function () {}
Foo.prototype = Object.create(Bar.prototype)
Foo.prototype.foo = 1;
Foo.prototy ...
...

Attachments (0)

Change History (6)

comment:1 Changed on 06/10/2014 at 09:32:07 AM by sebastian

  • Cc trev sebastian added

For reference: __proto__ is deprecated.

But I agree that using Object.create() makes code less readable in particular when using getter/setter:

Foo = function () {};
Foo.prototype = Object.create(
  Bar.prototype,
  {
    foo:
    {
      get: function()
      {
        return this._foo;
      },
      set: function(value)
      {
        this._foo = value;
      },
      enumerable: true
    }
  }
);

comment:2 Changed on 06/12/2014 at 11:50:42 AM by trev

There are some cases where it makes sense to use Object.create(), especially {__proto__: null}. However, wherever we use it to build up class hierarchies we should better wait for typed objects.

comment:3 Changed on 06/23/2014 at 08:47:57 AM by tschuster

  • Owner set to tschuster
  • Review URL(s) modified (diff)

comment:4 Changed on 06/27/2014 at 05:17:49 PM by tschuster

  • Resolution set to fixed
  • Status changed from new to closed

comment:5 Changed on 07/15/2014 at 05:05:56 PM by trev

  • Component changed from Unknown to Adblock-Plus-for-Firefox
  • Milestone set to Adblock-Plus-for-Firefox-next
  • Platform set to Firefox/Firefox Mobile

comment:6 Changed on 05/20/2015 at 02:22:39 PM by philll

  • Platform changed from Firefox/Firefox Mobile to Firefox

Made Firefox and Firefox mobile available as seperate platforms.

Add Comment

Modify Ticket

Change Properties
Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from tschuster.
 
Note: See TracTickets for help on using tickets.