"use strict" VS setTimeout
brendan at mozilla.org
Mon Sep 8 14:38:03 PDT 2014
Mark Miller wrote:
> Yes, this is indeed the only question that Andrea and I are raising in
> this thread. As you acknowledge, providing window here is a little
> strange. I quibble with "a little". When a surprise surprises by
> providing less authority than expected, I don't much care. When the
> surprise is that more authority is provided than expected, that's a
> more serious issue.
In 1995-96, this wasn't surprising. Frames and framesets were there,
also window.open. Calling otherWindowOrFrame.setTimeout(func, delay,
args) worked by passing otherWindowOrFrame bound to |this| when invoking
(Er, only in 1996 -- setTimeout originally took a string as first
parameter and eval'ed it, no function variant.)
It is what it was :-P.
The surprise may be in thinking of sloppy-mode global functions as
|this|-free procedures, when they were rather global object methods.
Calling otherWindowOrFrame.func(args) bound |this| as you would expect,
and calling func in the context of otherWindowOrFrame bound the same
|this| value. Sloppy FTW :-P.
Agreed it is an implicit parameter capability leak. I'm just giving the
view as it was in the past, which is enshrined not only in sloppy mode
as you note, but in the spec for Window::setTimeout.
More information about the es-discuss