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