Re: SVGLength behaviour tightening

On 2009-08-30 1:50 AM, Cameron McCormack wrote:
> I’d like to define the behaviour of SVGLength (and similarly for
> SVGAngle) when the attribute contains an invalid string such that:
> 
>   * unitType is SVG_LENGTHTYPE_UNKNOWN, value is NaN,
>     valueInSpecifiedUnits is NaN and valueAsString is "";

I think valueAsString should probably be the string "NaN", since that should
give the author a higher chance of noticing what they've done wrong when
debugging (e.g. scanning the property values on an element in the debugger), and
it's what NaN converts to when converted to a string in ECMAScript.

Saying that unitType will be SVG_LENGTHTYPE_UNKNOWN probably has knock-on
implications. Right now unitType can never be that value, so I don't think the
spec really addresses in all the places that it would have to, what the renderer
should do when it finds any of the various SVGLength attributes in that state.

>   * when assigning to value or validInSpecifiedUnits that the length is
>     set to that value in user units;

I think I'd rather this threw. The user then has a chance of having their
attention being drawn to the bug in their code earlier where it's easier to
locate, rather than finding that their SVG doesn't display as they expect and
having to figure out exactly which bit of the SVG or the scripts it embeds went
wrong.

>   * assigning to valueAsString or calling newValueSpecifiedUnits works
>     normally; and

Makes sense.

>   * calling convertToSpecifiedUnits throws an exception.

Makes sense.

> Also I’d like to make it clear that assigning to value will keep
> unitType as whatever it was before, and not just change it to
> SVG_LENGTHTYPE_NUMBER.

It does? Without looking, I thought setting 'value' set the value in user units
(changed unitType), and that to maintain the units you have to set
valueInSpecifiedUnits.

> Let me know if you think this is reasonable.


-- 
Jonathan Watt                                   http://jwatt.org/
Mozilla Corporation                       http://www.mozilla.com/

Received on Monday, 31 August 2009 04:46:37 UTC