New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong usage of RTCIceGatherOptions dictionaries on examples #464

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

Comments

Projects
None yet
3 participants
@murillo128

murillo128 commented Apr 13, 2016

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

This comment has been minimized.

Show comment
Hide comment
@robin-raymond

robin-raymond Apr 15, 2016

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

Contributor

robin-raymond commented Apr 15, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment