Why does object.observe not work for the value property of an input field?

I played with Object.observe in the latest version of Chrome and wondered why it does not work for the value property for text input. The code below will record a change to add / change the 'foo' property, but not to change the value property. Does anyone know why?

var myTextInput = document.getElementById('myTextInput'); Object.observe(myTextInput, function(changes){ changes.forEach(function(change) { console.log(change); }); }); myTextInput.value = 'test123'; myTextInput.foo = 'bar'; 
+5
source share
1 answer

I'm not sure why this is so, but since you are observing the attributes of a DOM element, a mutation observer api might be more appropriate.

-1
source

Source: https://habr.com/ru/post/1201513/


All Articles