Re: Canvas and Interactivity

Cameron McCormack:
> > A valueOf method on an object allows it to be converted into a primitive
> > when used with particular operators:

Jonathan Watt:
> 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?

In particular, unary ! won’t invoke valueOf on the object.  It just
evaluates to true for any object.

Even more troublesome would be == and !=.  If you had rect.x and rect.y
both be SVGAnimatedLengths whose values were 10, then rect.x == rect.y
will evaluate to false, since == will check for object identity.  You’d
need to do rect.x == +rect.y or something instead.

I’m beginning to think that there are too many exceptions and that this
will confuse authors.

Cameron McCormack ≝

Received on Friday, 24 July 2009 00:09:51 UTC