Description
The spec says that atan2
accepts two calculations, which must have the same type. However, the type is defined as only "length" for length values, and does not include the unit. In fact, the unit seems to be completely ignored.
For example, the following are equivalent despite having completely different units.
rotate: atan2(90px, 90px);
rotate: atan2(90px, 90vw);
In the WebKit implementation, however, the following are not equivalent. Presumably there is some unit conversion happening due to the units being compatible, but not sure if this is correct.
rotate: atan2(90px, 10px);
rotate: atan2(90px, 10in);
Further, when a calculation results in incompatible units, it's unclear what the behavior should be. For example:
rotate: atan2(90px, 10px + 10vw);
In WebKit, the second term seems to be ignored and result in the same value as rotate: atan2(90px, 10px)
. This seems like a bug, but I'm not sure what to expect here. Should 10vw
be computed and converted into px? What if the terms were reversed? Should 10px
be converted to vw
then? Should the units be ignored, resulting in atan2(90, 20)
? The spec doesn't say in which unit atan2
should be computed.
My question: what should the behavior be when the units of the arguments are different, but the types are the same? What should happen if a calculation cannot be simplified to a single number?
Perhaps a better question: why does this function accept units at all? Why not only allow calculations that resolve to a <number>
similar to some of the other math functions? Since the units aren't actually used, it just seems confusing.