Missing values in SVGPathElement API: What to do?

I just came across some undefined behavior in the spec that could easily be
defined. An example is the
http://www.w3.org/TR/SVG/paths.html#InterfaceSVGPathElement spec. It has
absolutely nothing to say about cases where the calling script does not
provide all of the necessary parameters. I could find no blanket statement
in the spec about what to do in such cases. The canvas spec is similarly
unhelpful.

e.g. what to do with
pathSegment = pathElement.createSVGPathSegCurvetoCubicAbs(1.0)

Logical choices are either throw an exception or zero the missing values.

Right now Chromium, and presumably WebKit, pass NaN through to the back
end, which is bad and which I plan to somehow fix. I haven't checkout other
browsers yet.

The question is, what fix?
1) Exception and return null object
2) Exception but fill missing values with 0
3) Silently fill in missing values with 0.

I'm liking 1 right now.

Regardless of which option we choose, I think it would be helpful to have a
generic statement about this situation somewhere in the spec.

Stephen.

Received on Thursday, 24 October 2013 15:33:41 UTC