- From: Nikolas Zimmermann <zimmermann@physik.rwth-aachen.de>
- Date: Sat, 27 Aug 2011 11:59:32 +0200
- To: "Tab Atkins Jr." <jackalmage@gmail.com>
- Cc: Dean Jackson <dino@apple.com>, Øyvind Stenhaug <oyvinds@opera.com>, www-svg@w3.org
Am 27.08.2011 um 03:53 schrieb Tab Atkins Jr.: > On Fri, Aug 26, 2011 at 6:36 PM, Dean Jackson <dino@apple.com> wrote: >> 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? > > I believe the specced behavior is buggy, and everyone should throw > when the original length is non-zero and the specified unit is > zero-length. When the original length is zero, the new value should > be zero in the new unit. > > If there's compat impact there, I suggest silently failing (as if you > attempted to specify an invalid value, which "Infinityem" is), but > throwing is preferable to me. Fully agreed!If you're interessted there are several tests in the LayoutTests/svg/dom/ directory that I mentioned in the other mail, that test such corner cases and the throwing. Maybe we could get this spec'ed, when to throw... and do it all consistently. (I could name many other cases where throwing is desired, but not spec'ed atm - I can make a list of all affected properties/function if there's interesst) Cheers, Niko
Received on Saturday, 27 August 2011 10:01:25 UTC