Re: [svgwg] What is the unit type after setting an SVGAngle or SVGLength's value

First comment:
_UNKNOWN (meaning a unit type unrecognized by the SVG DOM) is different from _UNSPECIFIED (meaning unitless-number as proxy for degrees). I'm assuming that you meant "shouldn't the unit type become SVG_ANGLETYPE__UNSPECIFIED".

Second comment:
The algorithms for `SVGLength` have the same issue, so this isn't specific to angles. Updating the issue title accordingly.

> Should the specification change to reflect reality?

That's the approach we've been taking elsewhere with the DOM.

>Note that I havent tested IE/Edge.

Running your test in IE 11 and MS Edge 17 I'm getting the following result:

```
unitType 3 radians is 3
orientType 2 - angle is 2
0.174533rad
unitType 5 - cm is 6
10px
```

Which is consistent with Chrome/Firefox when it comes to _angle_ units, but not for lengths. But it's also not setting the length to a unitless number, it's setting it to explicit px units, so it isn't matching the spec, either.

___________
For reference, the algorithm for `SVGAngle` is (and `SVGLength` matches):

> On setting `value`, the following steps are run:
>
> - If the SVGAngle object is read only, then throw a NoModificationAllowedError.
> - Let _value_ be the value being assigned to `value`.
> - Set the SVGAngle's [internal, private attribute] **value** to a `<number>` whose value is value.
> - If the SVGAngle reflects the base value of a reflected attribute, then reserialize the reflected attribute.

It's a rather confusing algorithm, with three different concepts named "value", and it does not explicitly say to change the unit type. However, the lack of unit on the new definitive "internal" representation of the value should affects the serialization of the attribute and all the getters on the object, including that for unit type.

To match implementations, the setters for angle and length would require a step for accessing the current unit type and converting the specified new _value_ for `value` into those units before updating the internal **value** with units.

-- 
GitHub Notification of comment by AmeliaBR
Please view or discuss this issue at https://github.com/w3c/svgwg/issues/478#issuecomment-425274997 using your GitHub account

Received on Thursday, 27 September 2018 23:34:52 UTC