{"action":"created","issue":{"url":"https://api.github.com/repos/w3c/webrtc-pc/issues/375","labels_url":"https://api.github.com/repos/w3c/webrtc-pc/issues/375/labels{/name}","comments_url":"https://api.github.com/repos/w3c/webrtc-pc/issues/375/comments","events_url":"https://api.github.com/repos/w3c/webrtc-pc/issues/375/events","html_url":"https://github.com/w3c/webrtc-pc/issues/375","id":115075819,"number":375,"title":"true as default values for dictionary is bad practice","user":{"login":"dontcallmedom","id":216410,"avatar_url":"https://avatars.githubusercontent.com/u/216410?v=3","gravatar_id":"","url":"https://api.github.com/users/dontcallmedom","html_url":"https://github.com/dontcallmedom","followers_url":"https://api.github.com/users/dontcallmedom/followers","following_url":"https://api.github.com/users/dontcallmedom/following{/other_user}","gists_url":"https://api.github.com/users/dontcallmedom/gists{/gist_id}","starred_url":"https://api.github.com/users/dontcallmedom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dontcallmedom/subscriptions","organizations_url":"https://api.github.com/users/dontcallmedom/orgs","repos_url":"https://api.github.com/users/dontcallmedom/repos","events_url":"https://api.github.com/users/dontcallmedom/events{/privacy}","received_events_url":"https://api.github.com/users/dontcallmedom/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-11-04T15:17:26Z","updated_at":"2015-12-09T23:21:14Z","closed_at":null,"body":"The [WebIDL spec](http://heycam.github.io/webidl/#idl-dictionaries) warns that:\r\n> [it] is strongly suggested not to use of true as the default value for boolean-typed dictionary members, as this can be confusing for authors who might otherwise expect the default conversion of undefined to be used (i.e., false). \r\n\r\nWe have true as default of:\r\n* `ordered` in `RTCDataChannelInit`\r\n* `voiceActivityDetection` in `RTCOfferAnswerOptions`\r\n* `send` and `receive` in `RTCRtpTransceiverInit`\r\n\r\nThis means that e.g. `createOffer({voiceActivityDetection:undefined})` keeps voice activity detection on, which is indeed confusing.\r\n\r\nI'm not sure if we still have room for change here; one option would be invert the property names (e.g. unordered, disableVoiceActivityDetection, receiveOnly, sendOnly)."},"comment":{"url":"https://api.github.com/repos/w3c/webrtc-pc/issues/comments/163433990","html_url":"https://github.com/w3c/webrtc-pc/issues/375#issuecomment-163433990","issue_url":"https://api.github.com/repos/w3c/webrtc-pc/issues/375","id":163433990,"user":{"login":"martinthomson","id":67641,"avatar_url":"https://avatars.githubusercontent.com/u/67641?v=3","gravatar_id":"","url":"https://api.github.com/users/martinthomson","html_url":"https://github.com/martinthomson","followers_url":"https://api.github.com/users/martinthomson/followers","following_url":"https://api.github.com/users/martinthomson/following{/other_user}","gists_url":"https://api.github.com/users/martinthomson/gists{/gist_id}","starred_url":"https://api.github.com/users/martinthomson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martinthomson/subscriptions","organizations_url":"https://api.github.com/users/martinthomson/orgs","repos_url":"https://api.github.com/users/martinthomson/repos","events_url":"https://api.github.com/users/martinthomson/events{/privacy}","received_events_url":"https://api.github.com/users/martinthomson/received_events","type":"User","site_admin":false},"created_at":"2015-12-09T23:21:14Z","updated_at":"2015-12-09T23:21:14Z","body":"An `undefined` value and omission from the dictionary are undetectably identical.\r\n\r\nOne approach would be to use enumerated strings rather than booleans:\r\n\r\n```js\r\ncreateOffer({voiceActivityDetection: 'disabled'})\r\nRTCRtpTransceiverInit('sendonly'||'recvonly'||'sendrecv'||'inactive')\r\n```\r\n\r\nGiven that each of these is only set to something other than a default rarely, I think that this would be OK.  Also, an enumerated value will make the API use more clearly self-documenting."}}