RE: MutationObserver does not observe state changes

There is, in theory, nothing that prevents this from working at least in the case of Object.observe, given that  objects can fire their own change records. Indeed, that capability is designed specifically to handle the getter/setter case.

From: Bradley Meck []
Sent: Sunday, July 28, 2013 10:30
Subject: MutationObserver does not observe state changes

Both MutationObservers *and* Object.observe are unable to listen for changes to state on <input> elements and the like. This seems like a pretty fundamental thing, to have one of these work (if not both). I expect most people to encounter some surprise when setting the state of an element but not observing them. I have come up with some questions due to this.

1. What is the official reason this is not supported?
2. Will there be a change due to this seemingly being a common expectation?
3. How should custom elements that have state be treated?
3. 1. Should stateful elements have to write to attributes to be observed?
3. 2. Should stateful elements write to host objects directly to be observed?

I have heard the following reasons (for checkboxes) that do not fully cover these points:

.checked etc. is a JS getter on the element. ( )
.checked does not map to an attribute (  )
MutationObservers are not to observe state, only DOM ( )


Received on Sunday, 28 July 2013 20:10:43 UTC