[whatwg] Example wrong in web workers

Anne van Kesteren annevk at opera.com
Mon Oct 26 07:00:48 PDT 2009


On Mon, 26 Oct 2009 13:57:10 +0100, Simon Pieters <simonp at opera.com> wrote:
> Web Workers has the following in some example (twice):
>
> // support being used as a shared worker as well as a dedicated worker
> if (this.onmessage) // dedicated worker
>    ....
>
> This ought to be doing something like (typeof this.onmessage !=  
> 'undefined') , as the event property is presumably 'null' by the time of  
> the test.

("onmessage" in this) might be somewhat safer fwiw.


-- 
Anne van Kesteren
http://annevankesteren.nl/



More information about the whatwg mailing list