Wrong usage of RTCIceGatherOptions dictionaries on examples #464

Closed
murillo128 opened this Issue Apr 13, 2016 · 1 comment

Projects

None yet

3 participants

@murillo128

Accroding to WebIDL definition, directories are asociative array data type with a fixed, ordered set of key–value pairs (https://www.w3.org/TR/WebIDL/#idl-dictionaries). The don't have a constructor, so in javascript a normal object mus be used when creating a dictionary.

But in several examples, for example, the RTCIceGatherOptions is created via a constructor (which is wrong).

// Create ICE gather options
var gatherOptions = new RTCIceGatherOptions();
gatherOptions.gatherPolicy = RTCIceGatherPolicy.relay;
gatherOptions.iceServers = [
  { urls: "stun:stun1.example.net" },
  { urls: "turn:turn.example.org", username: "user", credential: "myPassword", credentialType: "password" }
];

It sould be

// Create ICE gather options
var gatherOptions = {};
gatherOptions.gatherPolicy = RTCIceGatherPolicy.relay;
gatherOptions.iceServers = [
  { urls: "stun:stun1.example.net" },
  { urls: "turn:turn.example.org", username: "user", credential: "myPassword", credentialType: "password" }
];

or even better:

// Create ICE gather options
var gatherOptions = {
  gatherPolicy : RTCIceGatherPolicy.relay,
  gatherOptions.iceServers : [
    { urls: "stun:stun1.example.net" },
    { urls: "turn:turn.example.org", username: "user", credential: "myPassword", credentialType: "password" }
  ]
};
@robin-raymond robin-raymond added the 1.1 label Apr 13, 2016
@robin-raymond
Contributor

Correct, this needs to be fixed. Dictionaries are basically associative arrays and do not have constructors. Other languages without associative arrays like JS would be have more "fixed" definitions and possibly constructors, but not JS

@aboba aboba added PR exists and removed to-do-next-draft labels Apr 20, 2016
@aboba aboba referenced this issue Apr 20, 2016
Merged

Fix examples #483

@aboba aboba closed this Apr 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment