-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can FrozenArray<T> be used for a mutable attribute? #265
Comments
From the mediasession spec, it seems to set an internal slot when setting, which seems fine to me. The call to @domenic can you confirm? |
This is the only mutable
|
Oh, sorry. Misunderstood the question. Yes, from an API design perspective, I agree this looks terrible and counter intuitive. |
As far as I'm aware, that's correct.
The behavior you describe is the currently specced behavior, for what it's worth. Also note:
Unfortunately there aren't really better options here, which is why FrozenArray is specced the way it's specced. |
OK, sounds like this is not an oversight, thanks for confirming! I'll link to here from Intent to Ship: MediaSession API. |
I mean, I guess we can have the general discussion about whether we should allow writable FrozenArray attributes or whether they lead to bad API. In this case, it's certainly leading to a bad spec, because the way the setter for this attribute is defined is:
OK, but what is the new value? The new value is the output of the steps at https://heycam.github.io/webidl/#es-frozen-array (why do we not have a #es-to-frozen-array?) and hence is an ES Array object that has been frozen. OK, so we call into https://wicg.github.io/mediasession/#convert-artwork-algorithm and it does "for each entry in input's artwork" which is really not defined at all (in multiple ways; I think the spec editor got confused about what the type of the incoming thing is). This spec would be much better served by having a sequence there as the input; it would be harder to screw up. |
I filed w3c/mediasession#176 on the spec being confused. |
Thanks @bzbarsky! I guess I'll close this issue, if someone wants to avoid this pattern on the web platform please shout soon. |
https://heycam.github.io/webidl/#idl-frozen-array
https://heycam.github.io/webidl/#es-frozen-array
file:///usr/local/google/home/foolip/spec/mediasession/index.html#the-mediametadata-interface has this:
Does that work? I can't see anything in Web IDL that explicitly disallows it, but also don't understand what would happen if assigning to artwork.
@xxyzzzq @mounirlamouri
The text was updated successfully, but these errors were encountered: