melanke / Watch.JS

watch the changes of any object or attribute

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Watch HTML property without breaking functionality

ldstein opened this issue · comments

Any possible solutions to maintain the setter functionality of standard HTML element properties while watching them with Watch JS?

Example:

var element = document.createElement('div');
element.id = 'myId'; // This will set HTML attribute to 'myId'
console.log('Element:',element); // HTML attribute has been assigned properly
WatchJS.watch(element, 'id', function(){console.log('Element ID changed')});
element.id = 'aNewId'; // This should set HTML attribute to 'aNewId'
console.log('Element:',element); // However, WatchJS has broken this functionality

+1. The same happens with inputs.