[heycam/webidl] Does it make sense for an interface mixin to declare [Default] object toJSON()? (#979)

This appears in https://heycam.github.io/webidl/#example-tojson-default-inheritance-and-mixins:
```
[Exposed=Window]
interface A : B {
  attribute DOMString a;
};

[Exposed=Window]
interface B : C {
  attribute DOMString b;
};

[Exposed=Window]
interface C {
  [Default] object toJSON();
  attribute DOMString c;
};

interface mixin M1 {
  attribute DOMString m1;
};

interface mixin M2 {
  [Default] object toJSON();
  attribute DOMString m2;
};

interface mixin M3 {
  attribute DOMString m3;
};

interface mixin M4 {
  attribute DOMString m4;
};

A includes M1;
A includes M2;
B includes M3;
C includes M4;
```

Is the use of mixins here in any way significant, or would folding in the mixins result in exactly the same thing?

Put differently, if `[Default] object toJSON()` isn't scoped to the members of the interface mixin, is there anything special going on here?

Since https://heycam.github.io/webidl/#default-tojson-steps only operates on the inheritance stack, it seems like this example isn't something one would want to do, and doesn't clearly illustrate why "m3" wouldn't be included in the default `toJSON()` return value. I think that's because `B` has no `[Default] object toJSON()`, that "m3" is in a mixin isn't really relevant.

I suspect that this example could be from back when there was `implements` and "consequential interfaces", when things were more complicated.

If two `[Default] object toJSON()` operations on the same interface isn't valid, so putting it on a mixin would limit and affect the original interface in an unfortunate way. Maybe it should simply not be allowed?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/issues/979

Received on Friday, 23 April 2021 17:25:00 UTC