W3C home > Mailing lists > Public > public-script-coord@w3.org > January to March 2012

Re: [WebIDL] Worry on Enum type - binding seems inconsistently defined

From: Cameron McCormack <cam@mcc.id.au>
Date: Fri, 13 Jan 2012 00:08:13 +1100
Message-ID: <4F0EDB3D.9090106@mcc.id.au>
To: Arthur Barstow <art.barstow@nokia.com>
CC: public-script-coord <public-script-coord@w3.org>, Harald Alvestrand <harald@alvestrand.no>
Hi Harald.

Arthur Barstow:
> Hi Cameron, All - would you please respond to the question below about
> Web IDL? -Thanks, AB

Tab is right, I haven't been monitoring mailing lists as closely this 
week. :)

Harald Alvestrand:
> However, one detail makes the spec at this time a bit hard to
> understand: In section 3.5, the following is said:
>
> Note
>
> In the ECMAScript binding, assignment of an invalid string value to
> anattribute <http://dev.w3.org/2006/webapi/WebIDL/#dfn-attribute>is
> ignored, while passing such a value as anoperation
> <http://dev.w3.org/2006/webapi/WebIDL/#dfn-operation>argument results in
> an exception being thrown.
>
> However, in the ECMAScript binding, section 4.2.18, it says:
>
> An ECMAScript value V is converted to an IDL enumeration type value as
> follows (where E is the enumeration):
>
> 1. Let S be the result of calling ToString(V).
> 2. If S is not one of E’s enumeration values, then throw a TypeError.
> 3. Return the enumeration value of type E that is equal to S.
>
> I'm not sure it says the same thing; more clarity on the expected
> behaviour would be useful.
> (My personal opinion is that it's most useful if assigment throws an
> exception; silent failure is rarely the best option.)

The current behaviour is that invalid enumeration values when assigned 
to attributes are ignored, whereas when they're passed to operations 
they cause an exception to be thrown.  This was done at Anne's request, 
and the reasoning given was that that's the way the various HTML DOM 
properties tend to work.

Thanks,

Cameron
Received on Thursday, 12 January 2012 13:08:49 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:05 UTC