W3C home > Mailing lists > Public > public-script-coord@w3.org > October to December 2014

Re: This objects for static methods

From: Allen Wirfs-Brock <allen@wirfs-brock.com>
Date: Thu, 13 Nov 2014 11:40:16 -0800
Cc: "public-script-coord@w3.org" <public-script-coord@w3.org>
Message-Id: <B9A72063-086D-4F2F-BBB6-7D73D172FFE9@wirfs-brock.com>
To: Boris Zbarsky <bzbarsky@mit.edu>

On Nov 13, 2014, at 11:31 AM, Boris Zbarsky wrote:

> Currently Web IDL does not provide the "this" value a static method was invoked with to the implementation of the static method.
> 
> However, it seems like supporting subclassing might require access to this object.  For example, Promise.resolve actually uses the "this" value to construct the promise to be returned...
> 
> Is this an unlikely edge case, or should we adjust Web IDL to pass in the this value?
> 
> -Boris
> 

In Es6, there is nothing "static" about "static methods"  they are simply methods that are defined upon the constructor object.  It is very important that the "this" value is set correctly (and just like for any other object) when invoking such a method.  There are several usage patterns for constructor methods that depend upon correct behavior of "this", particularly when a constructor is extended by subclassing.
Received on Thursday, 13 November 2014 19:40:46 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:23 UTC