[whatwg] DOMTimeStamp binding

On Wed, 11 Feb 2009 15:03:01 -0800, Darin Adler <darin at apple.com> wrote:
> 
> On Feb 11, 2009, at 12:14 PM, Kartikaya Gupta wrote:
> 
> > I updated to Safari 3.2 on Windows (which looks it also has WebKit  
> > 525.27.1) and you're right, it is now showing "number" instead of  
> > "object". I guess this was changed not too long ago. So then my  
> > question is: why was it changed?
> 
> No, this was not changed.
> 
> I don't understand why you were getting that strange result, but  
> WebKit has always shown "number" for this. I went back to old  
> versions, including digging out a copy of Safari 2 and every version I  
> tested yields a number. There was never any code that attempted to  
> return anything except a number.

Well, I don't know what to tell you. Latest version of Chrome is still giving me a Date object. I don't know what version of WebKit it's using.

> More to the point, there's also a false premise in the specification's  
> claim that this should be a Date. The Date class in JavaScript boils  
> down to a double for its internal representation; I believe that's by  
> design and not just a detail of the WebKit implementation. So the  
> claim that a number, also a double, can't handle the entire range of  
> DOMTimestamp, but the Date class can is probably incorrect. Maybe  
> someone can give a specific example with details of how this would go  
> wrong ? I don?t think there is any such example.
> 

The DOM 3 Core actually says that an "integer type" in ECMAScript is too small. The ECMA-262 spec doesn't say anything about an "integer" type; all numbers are doubles, so I have no idea what the DOM spec is referring to. However, note that section 15.9.1.1 of ECMA-262 does says that the valid range for a Date object is slightly smaller than that representable by a double (8,640,000,000,000,000 milliseconds on either side of epoch, instead of 9,007,199,254,740,991), so there is a slight difference between returning a number and returning a Date. However, in practice it's unlikely those scenarios will be hit.

Cheers,
kats

Received on Thursday, 12 February 2009 07:08:59 UTC