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

Re: convertToSpecifiedUnits and zero units

From: Dean Jackson <dino@apple.com>
Date: Sat, 27 Aug 2011 11:36:13 +1000
Cc: www-svg@w3.org
Message-id: <5277CE69-5594-4402-BB05-23BB918B8F74@apple.com>
To: Řyvind Stenhaug <oyvinds@opera.com>

On 24/08/2011, at 10:49 PM, Řyvind Stenhaug wrote:

> Units
> 
> This doesn't seem to consider what happens if the unitType argument is a zero length, e.g. SVG_LENGTHTYPE_EMS when 1em=0px.
> 
> <svg xmlns="http://www.w3.org/2000/svg" font-size="0">
>   <rect width="100px"/>
>   <script type="application/ecmascript">
>      onload = function() {
>         try {
>            var width = document.querySelector('rect').width.baseVal;
>            width.convertToSpecifiedUnits(width.SVG_LENGTHTYPE_EMS);
>            alert(width.valueInSpecifiedUnits + ' ' + width.value);
>         } catch(e) {
>            alert(e);
>         }
>      }
>   </script>
> </svg>
> 
> Gecko and Presto give "Infinity NaN", failing to "[p]reserve the same underlying stored value".
> 
> WebKit throws NOT_SUPPORTED_ERR, although the spec only says it's "[r]aised if unitType is SVG_LENGTHTYPE_UNKNOWN or not a valid unit type constant (one of the other SVG_LENGTHTYPE_* constants defined on this interface)".
> 
> (When trying to convert a zero value, Presto gives "0 0", Gecko "NaN NaN" and WebKit still throws.)

The WebKit behaviour here is a bug which is easily fixed, but what values do you suggest we return?

Dean
Received on Saturday, 27 August 2011 01:40:36 GMT

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