Setting animVal.value?

Hi www-svg,

Is there a reason for making the contents of animVal readonly only when it
is animated?

For example, consider SVGAnimatedLength. For the animVal member we're told:

   If the given attribute or property is being animated, contains the
   current animated value of the attribute or property, and both the
   object itself and its contents are readonly. If the given attribute or
   property is not currently being animated, contains the same value
   as 'baseVal'.[1]

So it would seem that when the length is not being animated (which I presume
here to mean that there is no active interval nor a frozen animation
targeting that length) it is synonymous with baseVal, so that, for example,
setting animVal.value, is equivalent to setting baseVal.value.

On the other hand, when the length is being animated, the contents of
animVal are readonly.

So I wonder why anyone would try to set the contents of animVal? The only
use case I can conceive of is as a means to determine if the length is
currently being animated, i.e. try to set animVal.value and catch the
exception. If an exception is caught, then it is being animated.

Was that the intention of the specification? If not, can I suggest it would
be better to simply make the contents of animVal always readonly. This would
have the advantage of being more predictable for script (as well as being
easier to implement).

On a related note, the behaviour of readonly attributes here seems
inconsistent. On the one hand, animVal is readonly and the behaviour when
setting it is determined by WebIDL[2] which defers to the language-specific
behaviour for readonly attributes which might be to fail silently. When
animVal.value is readonly, however, it throws a DOMException
(NO_MODIFICATION_ALLOWED_ERR). That seems a little inconsistent.

Finally, I think there's a copy-and-paste bug in SVG 1.1 SE where the
description of the exceptions for SVGLength.value says:

  Raised when the list cannot be modified.[3]

I think "list" should be "length." This occurs in various places in this
part of the spec (e.g. SVGAngle etc. too).

Best regards,

Brian

[1] http://www.w3.org/TR/SVG11/types.html#InterfaceSVGAnimatedLength
[2] http://dev.w3.org/2006/webapi/WebIDL/#host-objects
[3]
http://dev.w3.org/SVG/profiles/1.1F2/publish/types.html#InterfaceSVGLength

Received on Friday, 7 August 2009 01:12:06 UTC