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

convertToSpecifiedUnits and zero units

From: Øyvind Stenhaug <oyvinds@opera.com>
Date: Wed, 24 Aug 2011 14:49:14 +0200
To: www-svg@w3.org
Message-ID: <op.v0pxwclkbunlto@oyvinds-desktop>
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.)

-- 
Øyvind Stenhaug
Core Norway, Opera Software ASA
Received on Wednesday, 24 August 2011 13:22:04 GMT

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