Re: [ambient light events LC] Feedback

On Tue, Dec 18, 2012 at 10:02 AM, Anne van Kesteren <annevk@annevk.nl> wrote:
> On Tue, Dec 18, 2012 at 6:58 PM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
>> It seems weird that enums would have a different "no value" behavior
>> than all the other attributes in the DOM.  Nulling things is the
>> common idiom here.
>
> For strings and especially enums you'd either have a defined value as
> default (which could be "default" or some such) or you'd use the empty
> string as the default (like XMLHttpRequest).
>
> Also, I don't think nulling things is the common idiom. Typical
> defaults for a list would be the empty list, 0 for a number, given
> that enums are strings, ...

Makes sense, I guess (though I'm not super happy with having to
explicitly add the empty string to every enum that's supposed to be
"nullable").  In that case, the IDL would be:

enum LightLevel { "dim", "normal", "bright", "" };
[Constructor (DOMString type, optional LightLevelEventInit eventInitDict)]
interface LightLevelEvent : Event {
    readonly attribute LightLevel value;
};
dictionary LightLevelEventInit : EventInit {
    LightLevel value = "";
};

~TJ

Received on Tuesday, 18 December 2012 18:48:39 UTC