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

Setting animVal.value?

From: Brian Birtles <birtles@gmail.com>
Date: Fri, 7 Aug 2009 11:11:24 +1000
Message-ID: <65fa1620908061811n4271a4c8nc26993dc529c0852@mail.gmail.com>
To: www-svg <www-svg@w3.org>
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,


[1] http://www.w3.org/TR/SVG11/types.html#InterfaceSVGAnimatedLength
[2] http://dev.w3.org/2006/webapi/WebIDL/#host-objects
Received on Friday, 7 August 2009 01:12:06 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 March 2017 09:47:18 UTC