convertToSpecifiedUnits and zero 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="" font-size="0">
    <rect width="100px"/>
    <script type="application/ecmascript">
       onload = function() {
          try {
             var width = document.querySelector('rect').width.baseVal;
             alert(width.valueInSpecifiedUnits + ' ' + width.value);
          } catch(e) {

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  

(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 UTC