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 27953 - Dictionaries with required properties shouldn't need to be optional
Summary: Dictionaries with required properties shouldn't need to be optional
Status: RESOLVED FIXED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: WebIDL (show other bugs)
Version: unspecified
Hardware: PC Linux
: P2 normal
Target Milestone: ---
Assignee: Cameron McCormack
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-04 01:30 UTC by Olli Pettay
Modified: 2015-04-17 05:12 UTC (History)
5 users (show)

See Also:


Attachments

Description Olli Pettay 2015-02-04 01:30:28 UTC
Doesn't really make sense to have optional dictionaries, if the dictionary has
required properties.


Gecko bug https://bugzilla.mozilla.org/show_bug.cgi?id=1129239
Comment 1 Tab Atkins Jr. 2015-02-04 02:55:50 UTC
No, it does.  It's reasonable to have an argument which is optional altogether, but if you *do* pass a dict, it *must* have certain properties.  (In other words, they're either required or optional as a block.)
Comment 2 Boris Zbarsky 2015-02-04 03:25:44 UTC
Except that's not how optional dictionaries behave in the spec at the moment.  Optional dictionaries always have the default value null (or Object.create(null) if you prefer to think of it that way; the behavior is identical), so not passing the argument for an optional dictionary is the same thing as passing null or Object.create(null), which is guaranteed to throw if the dictionary has a required member.
Comment 3 Cameron McCormack 2015-04-17 05:01:07 UTC
I think if we want to ensure that APIs that allow an empty dictionary value to also be specified as undefined (and probably we do), and we also want to allow APIs with arguments with required dictionary members, then allowing the "optional" keyword to be dropped iff the dictionary does have required members makes sense.