- From: Boris Zbarsky <notifications@github.com>
- Date: Tue, 02 Apr 2019 09:49:13 -0700
- To: heycam/webidl <webidl@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <heycam/webidl/issues/702/479090148@github.com>
This is a little subtle. There are four ways you can write an attribute declaration:
```
inherit attribute type name;
readonly attribute type name;
attribute type name;
```
Interfaces and partial interfaces allow all four types. The first one is allowed by this production under [_ReadWriteAttribute_](https://heycam.github.io/webidl/#prod-ReadWriteAttribute) (which is one of the options under [_InterfaceMember_](https://heycam.github.io/webidl/#prod-InterfaceMember)):
```
inherit ReadOnly AttributeRest
```
The second one is allowed by having [_ReadOnlyMember_](https://heycam.github.io/webidl/#prod-ReadOnlyMember) in [_InterfaceMember_](https://heycam.github.io/webidl/#prod-InterfaceMember). [_ReadOnlyMember_](https://heycam.github.io/webidl/#prod-ReadOnlyMember) then allows readonly attributes via [_ReadOnlyMemberRest_](https://heycam.github.io/webidl/#prod-ReadOnlyMemberRest) allowing [_AttributeRest_](https://heycam.github.io/webidl/#prod-AttributeRest). Finally, the third one is allowed by [_ReadWriteAttribute_](https://heycam.github.io/webidl/#prod-ReadWriteAttribute) including _AttributeRest_ directly.
On the other hand, mixins only allow the second and third option, by having
```
ReadOnly AttributeRest
```
under _MixinMember_. Note that the [_ReadOnly_](https://heycam.github.io/webidl/#prod-ReadOnly) production allows either the keyword "readonly" or nothing at all, so that grammar allows both readonly and writable attributes. This is explicitly called out in the [list of productions that attributes can match](https://heycam.github.io/webidl/#idl-attributes).
So mixins do in fact allow non-readonly regular attributes. What they don't allow is the use of the "inherit" keyword on them, because that doesn't make much sense: you can't define an attribute getter to "do what the thing we inherit from does" if you have no idea what you're inheriting from!
The grammar does technically allow `inherit readonly attribute type name;` but the prose for the "inherit" bit explicitly says:
> inherit must not appear on a read only attribute or a static attribute
so that would not be valid IDL. It might be nice to adjust the grammar to disallow it, though, by removing the _ReadOnly_ bit from that branch of _ReadWriteAttribute_. I filed https://github.com/heycam/webidl/issues/703 on that.
Closing, because I think this issue as filed is not an issue.
--
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/702#issuecomment-479090148
Received on Tuesday, 2 April 2019 16:49:35 UTC