Re: [WICG/webcomponents] Observable Properties (Issue #951)

The platform does include such APIs. In Web IDL parlance they’re [indexed property](https://webidl.spec.whatwg.org/#idl-indexed-properties) and [named property](https://webidl.spec.whatwg.org/#idl-named-properties) and are defined in terms of the `getter`, `setter`, and `deleter` [special operations](https://webidl.spec.whatwg.org/#idl-special-operations).

These are generally considered a legacy design pattern which isn’t used for new interfaces. It tends to lead to surprise collisions with “normal” members and even though the algorithms are well-defined, no two agents actually implement them the same (try messing with `localStorage.getItem` and a localStorage entry named `getItem` in various ways using delete, assignment, etc in a few browsers to get a feel for just how chaotic the interop issues still are). However there are two built-in elements that implement them:

- [HTMLFormElement](https://html.spec.whatwg.org/multipage/forms.html#the-form-element:~:text=getter%20Element%20(unsigned%20long%20index)%3B%0A%20%20getter%20(RadioNodeList%20or%20Element)%20(DOMString%20name)%3B) implements named property and indexed property getters
- [HTMLSelectElement](https://html.spec.whatwg.org/multipage/form-elements.html#the-select-element:htmloptionelement:~:text=getter%20HTMLOptionElement%3F%20item(unsigned%20long%20index)%3B) implements an indexed property getter

-- 
Reply to this email directly or view it on GitHub:
https://github.com/WICG/webcomponents/issues/951#issuecomment-1190454942

You are receiving this because you are subscribed to this thread.

Message ID: <WICG/webcomponents/issues/951/1190454942@github.com>

Received on Wednesday, 20 July 2022 15:51:36 UTC