Updated our WebIDL page to include this new information:

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

Let me know if you'd rather see something different here.

Chris Mills
MDN content lead & writers' team manager
Mozilla Developer Network <https://developer.mozilla.org/en-US/>
@chrisdavidmills <https://twitter.com/chrisdavidmills>


On Tue, Sep 24, 2019 at 6:20 PM Boris Zbarsky <bzbar...@mit.edu> wrote:

> The way mixins are done in IDL has changed syntax somewhat.  Instead of
> having a [NoInterfaceObject] interface and an "implements" statement,
> the new setup looks like this:
>
>    interface A {};
>
>    interface mixin B {
>      void somethingMixedIn();
>    }
>
>    A includes B;
>
> In-tree IDL has been updated to the new syntax.  Support for the old
> syntax has not been removed yet, but will be as soon as that patch is
> reviewed; please do not add new IDL using "implements".
>
> The new setup is a little less featureful: mixins have no inheritance
> and cannot include other mixins.  They _do_ support partials, so you can
> do:
>
>    interface A {};
>    interface mixin B {};
>    partial interface mixin B {
>      void somethingMixedIn();
>    };
>    A includes B;
>
> A mixin and its partials have to in the same .webidl file, just like our
> existing rules for interfaces.  This is not enforced yet, but will be
> soon.  Similarly, the "A includes B" statement must be in the same
> .webidl file as the definition of interface A.  This part _is_ enforced.
>
> Mixins have somewhat restricted syntax compared to interfaces (e.g. do
> not allow mixing in constructors, getter/setter operations, iterable
> declarations, etc).  This should not be a problem in practice, and
> certainly wasn't for anything we had in-tree.
>
> -Boris
> _______________________________________________
> dev-platform mailing list
> dev-platform@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-platform
>
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to