[heycam/webidl] ObservableArray without assignment (#1027)

As a follow-up to my comment [here](https://github.com/WICG/construct-stylesheets/issues/45#issuecomment-830468542), and as a compromise position, I'd like to make one last push to make assignment on an ObservableArray attribute throw.

The downside to the current behavior ([as noted](https://github.com/WICG/construct-stylesheets/issues/45#issuecomment-825055766)) is that JavaScript developers might not be aware of the copy semantics that assignment has, and will assume that the Put results in changing the ObservableArray to refer the the same instance that was assigned (and that subsequent updates to that instance will be reflected in the ObservableArray). To avoid potential confusion, having assignment throw will be sure to prevent any failed expectations. (And such an artificial restriction can be lifted in the future without back-compat concern if necessary.)

There seemed to be at least some support for this idea in the linked issue thread.

Caveat: such a change would not be backwards-compatible with the `adoptedStyleSheets` property, which *depends* on assignment today to change/update the set of adopted sheets.

I'm interested in seeing a mutually acceptable compromise between supporters and objectors--if this proposed change can be that compromise that leads to general agreement on the behavior for ObservableArray among implementers, then I view the [loss of good ergonomics](https://github.com/WICG/construct-stylesheets/issues/45#issuecomment-825055766) as acceptable. The alternative is the status quo, now [merged into CSSOM for `adoptedStyleSheets`](https://drafts.csswg.org/cssom/#ref-for-idl-observable-array) which I'm happy to support if compromise cannot be reached.

Related folks: @rniwa, @emilio, @annevk, @mfreed7, @domenic

-- 
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/1027

Received on Monday, 4 October 2021 19:30:57 UTC