getsentry / rrweb

record and replay the web
https://www.rrweb.io/
Other
9 stars 5 forks source link

Handle unchanged attributes in mutation observer #71

Closed mydea closed 1 year ago

mydea commented 1 year ago

Apparently, the mutation observer triggers each time an attribute/class is set, even if it does not change.

For example:

el.setAttribute('attr', 'val');
el.setAttribute('attr', 'val');
el.setAttribute('attr', 'val');

or

el.classList.add('my-class');
el.classList.add('my-class');
el.classList.add('my-class');

will each trigger the mutation observer three times, even though the DOM doesn't actually change.

We should check if the value doesn't change and skip doing any work in this case.

mydea commented 1 year ago

Hmm, actually this is already handled it seems 😅 was just buried a bit down in the method, so I guess nothing to do here.