Re: Using enums to avoid default true in "settings dictionaries" (#466, #467, #471)

On 2/23/16 2:17 PM, Adam Bergkvist wrote:
> On 2016-02-23 16:30, Jan-Ivar Bruaroey wrote:
>> How about "order"? Not different enough?
> That would be an improvement. Both for the settings dictionary member
> and the readonly attribute.

Great! So lets add:

   enum RTCDataChannelOrder {
     "ordered",
     "unordered"
   };

   dictionary RTCDataChannelInit {
     RTCDataChannelOrder order = "ordered";
     // ...
   };

   interface RTCDataChannel : EventTarget {
     readonly attribute RTCDataChannelOrder order;
     // ...
   };


Then there are no surprises:

   var dc1 = pc.createDataChannel(label, { order: "unordered" });
   var dc2 = pc.createDataChannel(label, { order: "ordered" });
   var dc3 = pc.createDataChannel(label, { order: undefined });
   var dc4 = pc.createDataChannel(label);

   console.log(dc1.order); // unordered
   console.log(dc2.order); // ordered
   console.log(dc3.order); // ordered
   console.log(dc4.order); // ordered


This seems to solve the "avoid having true as default value" problem [1] 
without any downsides.

[1] http://heycam.github.io/webidl/#dfn-dictionary-member-default-value

.: Jan-Ivar :.

Received on Friday, 26 February 2016 02:57:15 UTC