You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Why is attributeChangedCallback synchronous despite the fact that DOM MutationEvents were removed because they were synchronous and deemed to be a bad thing?
So, in effect, attributeChangedCallback restores the "bad" nature of DOM MutationEvents: 1000 custom elements with attributeChangedCallbacks is essentially equivalent to 1000 elements with DOMAttrModified events, yet this has not been considered a bad thing in the case of custom elements.
Perhaps there are a few questions here actually:
Why is it ok for custom elements to have synchronous events and not for DOM MutationEvents?
Why don't we make attributeChangedCallback async like MutationObserver?
Why didn't we fix MutationEvents then? For example, we could have easily made MutationEvents fire "batched" in a microtask, or fire for specified attributes only as in el.addEventListener('DOMAttrModified:some-attribute', ...) or something.
The text was updated successfully, but these errors were encountered:
That still doesn't explain why CE reactions are sync and MO are async, when in the end, they effectively achieve the same thing but from different perspectives (first person vs third person).
The real reason I wonder about this is ultimately because one paradigm (MutationObserver reactions) are incredibly and unnecessarily more complicated than the others (CustomElement reactions and DOM Mutation events).
Why is
attributeChangedCallback
synchronous despite the fact that DOMMutationEvent
s were removed because they were synchronous and deemed to be a bad thing?So, in effect,
attributeChangedCallback
restores the "bad" nature of DOM MutationEvents: 1000 custom elements withattributeChangedCallback
s is essentially equivalent to 1000 elements withDOMAttrModified
events, yet this has not been considered a bad thing in the case of custom elements.Perhaps there are a few questions here actually:
attributeChangedCallback
async likeMutationObserver
?el.addEventListener('DOMAttrModified:some-attribute', ...)
or something.The text was updated successfully, but these errors were encountered: