I would like to know when certain properties of an arbitrary object change.
I read the answer to this question: "extend setter default object" which seemed to suggest the solution using getters and setters. However, I tried to use it to trap changes to both the id
and style
properties of a DOM object and it did not work. One strange thing I observed is that as soon as I create a setter for the id
field is the original id
field vanishes, so attempts to read or write the value fails. As the property may be a DOM property, which sometimes aren't simple variables, I can't simply create my own variable as I can't arbitrarily re-create whatever underlying functionality is generating the value.
All I really want to do is detect when the property changes, and pass the change through transparently.
Some further research led me to this page presenting a polyfill for Object.watch. However, while this watch function appears to let me see when the properties of an object change, the actual properties wind up not being changed at all.