Closed mydea closed 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.
Hmm, actually this is already handled it seems 😅 was just buried a bit down in the method, so I guess nothing to do here.
Apparently, the mutation observer triggers each time an attribute/class is set, even if it does not change.
For example:
or
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.