This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 11085 - Define what "this" value to use for setTimeout(function)
Summary: Define what "this" value to use for setTimeout(function)
Status: RESOLVED FIXED
Alias: None
Product: HTML WG
Classification: Unclassified
Component: LC1 HTML5 spec (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Ian 'Hixie' Hickson
QA Contact: HTML WG Bugzilla archive list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-19 01:41 UTC by Cameron McCormack
Modified: 2011-08-04 05:35 UTC (History)
4 users (show)

See Also:


Attachments

Description Cameron McCormack 2010-10-19 01:41:00 UTC
The "get the timed task" algorithm currently says:

  1. If the first argument to the invoked method is an object that has an
  internal [[Call]] method, then return a task that checks if the entry for
  handle in list has been cleared, and if it has not, calls the aforementioned
  [[Call]] method with as its arguments the third and subsequent arguments to the
  invoked method (if any), and abort these steps.

This doesn't say what to use as the "this" value.
Comment 1 Ian 'Hixie' Hickson 2011-01-11 21:10:49 UTC
"this" here should be the WindowProxy object, right? How do I spec that?
Comment 2 Cameron McCormack 2011-01-11 21:32:45 UTC
I think that's right.  (I am still not clear on all of the distinctions between the Window and WindowProxy objects in the spec.  I notice that that section talks only about Window objects.)  Since you mention [[Call]] directly, it would be fine just to mention what the this value is at that point.  So, something like:

  ... calls the aforementioned [[Call]] method with as its arguments the third
  and subsequent arguments to the invoked method (if any) and with BLAH as the
  *this* object, ...

where BLAH is the method context (if that is a Window) or the script's global object (if it's a WorkerUtils).  Or maybe the script's global object is the same for both of these cases?
Comment 3 Ian 'Hixie' Hickson 2011-02-11 23:50:29 UTC
Reading the JS spec, it seems to me that section "10.4.3 Entering Function Code" says that all I have to do is set /thisArg/ to /undefined/ to get the effect we're looking for here. I already have some prose in the HTML spec about setting ThisBinding in certain cases to use WindowProxy rather than Window.

EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Accepted
Change Description: see diff given below
Rationale: Concurred with reporter's initial comments.
Comment 4 contributor 2011-02-11 23:50:44 UTC
Checked in as WHATWG revision r5879.
Check-in comment: Define 'this' for setTimeout functions
http://html5.org/tools/web-apps-tracker?from=5878&to=5879
Comment 5 Michael[tm] Smith 2011-08-04 05:35:10 UTC
mass-move component to LC1