W3C home > Mailing lists > Public > public-script-coord@w3.org > January to March 2013

[webidl.js] Implement the any type

From: François REMY <fremycompany_pub@yahoo.fr>
Date: Thu, 10 Jan 2013 12:01:25 +0100
Message-ID: <DUB002-W141A54DA4CCDC0D58D489CEA52A0@phx.gbl>
To: extensiblewebwebidl.js <reply+i-9734213-995692b9a7a2220a2d186a9d4ca28890d7904718-364405@reply.github.co>
CC: "public-script-coord@w3.org" <public-script-coord@w3.org>, "cam@mcc.id.au" <cam@mcc.id.au>, "public-nextweb@w3.org" <public-nextweb@w3.org>
Hi guys, I found yet another possible issue with the WebIDL spec.


In the "any" conversion algorithm, it's specified that if the ECMAScript value is a Number, it should be converted using the 'double' conversion at section 4.2.14. 

  [http://dev.w3.org/2006/webapi/WebIDL/#es-any]

In this section, it's said to throw a type error if the number has the value "NaN" or is infinite.

  [http://dev.w3.org/2006/webapi/WebIDL/#es-double]


I can prove this is not what browsers do by looking at the setTimeout function, which takes 'any' arguments. 

  [http://www.w3.org/TR/2011/WD-html5-20110525/timers.html#timers]

In the 'get timeout' algorithm that converts the received value into a number, we can read the following:

  "If timeout is an Infinity value, a Not-a-Number (NaN) value, or negative, let timeout be zero."
  [http://www.w3.org/TR/2011/WD-html5-20110525/timers.html#get-the-timeout]

I tried calling setTimeout(alert, Number.NaN) and that works perfectly fine in all browsers (alert is executed straightaway), and that doesn't throw a conversion type error because of the 4.2.14 algorithm.

My belief is that the specification should have referenced the "4.2.15 unrestricted double" algorithm instead.


I sent this mail in CC to Cameron & the public-script-coord mailing list, let's see what their response will be. 		 	   		  
Received on Thursday, 10 January 2013 11:01:59 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:08 UTC