Re: innerHTML and setTimeout

On 09/04/07, Dao Gottwald <dao@design-noir.de> wrote:
> > In my opinion, timer events belong in the DOM, as part of a
> > documentation of the de facto standard Window object (which should be
> > part of the DOM) or possibly as part of the DOM (3?) Events
> > specification.
>
> Err, no. Timeouts != events.

That depends on perspective. In the JavaScript execution model the
browser is apparently singly threaded. When events and timers are
taken into consideration, they both end up in an execution queue, each
queued block of code running to completion in order. (Ordered, except
for possible disruption of the queue from applets, plugins or halting
functions such as alert which can cause events to be queued in between
calling the halting function and the completion of the block of code
that called the halting function.)

In that light, timers can be seen as events, sharing the same event
queue and all. setTimeout and setInterval could conceptually be seen
as interfaces scheduling one or several timer event and setting a
listener on that event. They do not partake in the event cascade
through the document though, because they are not related to the
document, only the window object.
-- 
David "liorean" Andersson

Received on Tuesday, 10 April 2007 10:02:41 UTC