W3C home > Mailing lists > Public > public-script-coord@w3.org > October to December 2011

Dictionaries in WebIDL

From: Ross Burton <ross@burtonini.com>
Date: Fri, 7 Oct 2011 13:45:51 +0100
Message-ID: <CAAnfSTtdhsgY-GqG+tWWGoyCTE3hbKOeNh-uL0c8cgCqH9QxWA@mail.gmail.com>
To: public-script-coord@w3.org

I'm trying to express in WebIDL an interface with a string attribute
"uri", and a string-string dictionary "options" that has no
restrictions on the keys.

In JS this would be something like this as a literal:

 uri: "",
 options: {}

Now I came up with the following WebIDL:

 /* arbitrary key-value hints */
 dictionary Options {};

 interface Item {
   attribute DOMString uri;
   attribute Options options;

Which seems reasonable to me but the specification says "Dictionaries
must not be used as the type of an attribute, constant or exception
field".  Maybe I'm misreading the spec but doesn't this make my IDL
invalid?  Is there a better way of expressing what I want?

Related: is there a good tutorial/annotated reference/set of examples
for WebIDL?  The spec is quite... concise and isn't that great for
learning from. :)

Received on Friday, 7 October 2011 12:46:40 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:04 UTC