This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 29151 - Clarify if assigning wrong enumeration value to an attribute should throw
Summary: Clarify if assigning wrong enumeration value to an attribute should throw
Status: RESOLVED WORKSFORME
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: WebIDL (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Cameron McCormack
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-25 19:48 UTC by Chris Dumez
Modified: 2016-10-21 21:05 UTC (History)
4 users (show)

See Also:


Attachments

Description Chris Dumez 2015-09-25 19:48:13 UTC
I may have missed something but I initially read the ECMAScript bindings section for enumerations [1] and it said to throw a TypeError if the input value is not a valid value for this enumeration.

However, I then noticed a Note in the non-ECMAScript enumeration section [2] that says we should only throw when converting operation arguments but NOT when assigning an attribute. If this is really the intended behavior for ECMAScript bindings, I think it would be worse specifying it in [1] instead of simply in a Note.

[1] https://heycam.github.io/webidl/#es-enumeration
[2] https://heycam.github.io/webidl/#idl-enums
Comment 1 Chris Dumez 2015-09-25 19:50:58 UTC
I work on WebKit and looking at our ECMAScript bindings, it seems that we behave as indicated in the Note:
"""
Note
In the ECMAScript binding, assignment of an invalid string value to an attribute is ignored, while passing such a value as an operation argument results in an exception being thrown.
"""
Comment 2 Boris Zbarsky 2015-09-25 20:03:24 UTC
This behavior is specified in https://heycam.github.io/webidl/#dfn-attribute-setter step 4 which doesn't invoke https://heycam.github.io/webidl/#es-enumeration at all but instead uses a slightly different algorithm.  So https://heycam.github.io/webidl/#es-enumeration is only invoked for operation arguments, dictionary members, sequence members, and so forth.

I agree that it's a bit confusing to do it that way, but it avoids the problem of saying in https://heycam.github.io/webidl/#es-enumeration that the behavior depends on "where it's called from", which is a bit hard to define precisely.
Comment 3 Chris Dumez 2015-09-25 21:05:17 UTC
(In reply to Boris Zbarsky from comment #2)
> This behavior is specified in
> https://heycam.github.io/webidl/#dfn-attribute-setter step 4 which doesn't
> invoke https://heycam.github.io/webidl/#es-enumeration at all but instead
> uses a slightly different algorithm.  So
> https://heycam.github.io/webidl/#es-enumeration is only invoked for
> operation arguments, dictionary members, sequence members, and so forth.
> 
> I agree that it's a bit confusing to do it that way, but it avoids the
> problem of saying in https://heycam.github.io/webidl/#es-enumeration that
> the behavior depends on "where it's called from", which is a bit hard to
> define precisely.

Ok, thank you. I assumed there was something I missed in the spec what I wanted to confirm. I think it is fine to leave as is then.