Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

New Web IDL constructor syntax

53 views
Skip to first unread message

Boris Zbarsky

unread,
Sep 12, 2019, 8:23:44 PM9/12/19
to
As of today, the syntax for Web IDL constructors no longer involves an
extended attribute on the interface. There's now something that looks
more like a method named "constructor" with no explicitly-defined return
type.

So this:

[Constructor(DOMString str)]
interface MyInterface {};

is now written like so:

interface MyInterface {
constructor(DOMString str);
};

This means we can now specify extended attributes on the constructor,
and therefore we no longer assume that all constructors throw. If yours
does, you can use [Throws] in the usual way to indicate that:

interface ThrowingConstructor {
[Throws] constructor();
};

It may take some time for specifications to update to the new syntax
because not all of the tooling is updated yet; see
https://github.com/heycam/webidl/issues/778 which tracks that. So in
the meantime, including new spec IDL that uses constructors may require
some hand-editing to get it into the new form.

-Boris

Christopher Mills

unread,
Sep 13, 2019, 3:55:22 AM9/13/19
to Boris Zbarsky, dev-platform
Thanks Boris.

I've updated the MDN WebIDL guide to include a section on the new syntax:

https://developer.mozilla.org/en-US/docs/MDN/Contribute/Howto/Write_an_API_reference/Information_contained_in_a_WebIDL_file#New_constructor_syntax

(and the new Chrome-only syntax you talked about in your other mail:
https://developer.mozilla.org/en-US/docs/MDN/Contribute/Howto/Write_an_API_reference/Information_contained_in_a_WebIDL_file#Available_only_in_system_code
)

Chris Mills
MDN content lead & writers' team manager
Mozilla Developer Network <https://developer.mozilla.org/en-US/>
@chrisdavidmills <https://twitter.com/chrisdavidmills>
> _______________________________________________
> dev-platform mailing list
> dev-pl...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-platform
>

Boris Zbarsky

unread,
Sep 13, 2019, 8:42:58 AM9/13/19
to
On 9/13/19 3:54 AM, Christopher Mills wrote:
> I've updated the MDN WebIDL guide to include a section on the new syntax:

Chris,

Thank you!

-Boris
0 new messages