W3C home > Mailing lists > Public > www-svg@w3.org > July 2009

Re: Canvas and Interactivity

From: Jonathan Watt <jwatt@jwatt.org>
Date: Thu, 23 Jul 2009 23:25:18 +0200
Message-ID: <4A68D53E.1060708@jwatt.org>
To: Robert O'Callahan <robert@ocallahan.org>, Jeff Schiller <codedread@gmail.com>, anthony.grasso@cisra.canon.com.au, www-svg <www-svg@w3.org>
On 7/15/09 10:55 AM, Cameron McCormack wrote:
> Robert O’Callahan:
>> What does that mean for those of us who fear WebIDL?
> 
> :)
> 
> A valueOf method on an object allows it to be converted into a primitive
> when used with particular operators:

Wouldn't it always be the case, not just for particular operators? If not, when
would rect.x evaluate to a Number, and when would it evaluate to an
SVGAnimatedLength?

>   >>> rect = { x: { valueOf: function() { return 12.5 } } }
>   [object Object]
>   >>> rect.x + 50
>   62.5
> 
> The internal [[DefaultValue]] method by default in ES232 calls valueOf
> on the object.  So another way to achieve the same effect (the
> SVGAnimatedLength object acting like a Number in some contexts) would be
> to override that [[DefaultValue]].
>  
>   http://bclary.com/2004/11/07/#a-8.6.2.6
> 
> It’s not perfect, though.  And it feels a bit too “clever”.  It also
> wouldn’t work for SVGAnimatedBoolean objects, since the ECMAScript
> ToBoolean() operator doesn’t invoke [[DefaultValue]] like ToNumber()
> does.
> 
> If we could get away with it, I agree that it would be better to just
> replace the SVGAnimated* things with something simpler like what you
> suggest.
> 
Received on Thursday, 23 July 2009 21:25:57 GMT

This archive was generated by hypermail 2.3.1 : Friday, 8 March 2013 15:54:42 GMT