W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2013

Re: document.register and ES6

From: David Bruant <bruant.d@gmail.com>
Date: Wed, 06 Feb 2013 11:36:03 +0100
Message-ID: <51123213.9070608@gmail.com>
To: Boris Zbarsky <bzbarsky@MIT.EDU>
CC: Erik Arvidsson <arv@chromium.org>, public-webapps <public-webapps@w3.org>, Dimitri Glazkov <dglazkov@google.com>, Daniel Buchner <daniel@mozilla.com>
Le 06/02/2013 11:27, Boris Zbarsky a écrit :
> On 2/5/13 10:28 PM, Boris Zbarsky wrote:
>> And the point is that document.register changes the [[Construct]] of
>> MyButton but does nothing else with it?
>
> Note that I'm still checking how feasible this is in SpiderMonkey on 
> any sort of finite timeframe, if we do decide to do this. Functions 
> right now don't have a [[Construct]] member in spidermonkey that's 
> stored on a function directly; it's stored on a shared data 
> structure.  So it's impossible to change the [[Construct]] of a single 
> function as things stand...
As a band-aid short-term type of solution, the exposed function could be 
a proxy to the actual function with a specific construct trap. I've just 
tried the following on Firefox Aurora and it does what you'd expect:

     function f(){
         console.log('f call')
     }

     var pf = new Proxy(f, {
         construct: function(target){
             console.log('pf construct');
             target();
         }
     })

     pf();
     new pf();

David
Received on Wednesday, 6 February 2013 10:36:32 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:57 GMT