Re: [WebIDL] prototype chains, multiple inheritance, mixin interfaces

On Sat, Nov 20, 2010 at 8:11 AM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
> On 11/20/10 5:32 AM, Jonas Sicking wrote:
>>>
>>> A related issue.  What happens if a single mixin interface wants to mix
>>> in
>>> into multiple concrete interfaces?  Think nsIDOMEventTarget, unless some
>>> interface inheritance chains get changed.
>>
>> Node implements EventTarget;
>> Window implements EventTarget;
>> Worker implements EventTarget;
>> etc..
>
> Yes, but then if script wants to override addEventListener it has to do it
> separately on everything that implements EventTarget, right?  That's ok, I
> guess...

Yup. I think that's the case in every proposal brought up so far,
including what's in the spec now. It's just a limitation of having a
single prototype chain.

This is why MI even of interfaces should be avoided and why we should try to do

class EventTarget {
  ...
};
class Node : EventTarget ...

instead of

interface EventTarget {
  ...
};
Node implements EventTarget

/ Jonas

Received on Saturday, 20 November 2010 17:53:55 UTC