W3C home > Mailing lists > Public > public-script-coord@w3.org > April to June 2014

[WebIDL] Dictionary with attribute set to 'undefined' counts as set?

From: Dirk Schulze <dschulze@adobe.com>
Date: Sat, 14 Jun 2014 17:45:07 +0000
To: "public-script-coord@w3.org" <public-script-coord@w3.org>
Message-ID: <B662CE17-8593-4095-86D8-C05064BCA2F1@adobe.com>

I have a question to dictionaries:

If I have a dictionary like this

	var dic = {x: 1, y: undefined, z: 1, w: 1};

and pass it as argument to DOMPoint: 

	new DOMPoint(dic);

How should the attribute value of DOMPoint.y look like?

Should it be:
a) 0 because dic.y doesn’t count as initialized and it take the default initial value of DOMPoint.y?
b) NaN because dic.y counts as initialized and undefined is transformed to NaN since the attribute value of y is of type Number?

The relevant spec is Geometry Interfaces. The relevant IDL looks like this:

dictionary DOMPointInit {
    unrestricted double x = 0;
    unrestricted double y = 0;
    unrestricted double z = 0;
    unrestricted double w = 1;

[Constructor(optional DOMPointInit point)]
interface DOMPoint : DOMPointReadOnly {
    inherit attribute unrestricted double x;
    inherit attribute unrestricted double y;
    inherit attribute unrestricted double z;
    inherit attribute unrestricted double w;

Received on Saturday, 14 June 2014 17:45:40 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:21 UTC