When automatic refresh of alerts is turned on, all DOM elements are replaced on every call.
I think this is undesirable, because it can cause animations and other initialization behavior to repeat. It's necessary if an alert was edited since the last refresh, but otherwise it should not be.
Apply the patch for Issue #3337688 π removeStaleAlerts() always removes all alerts Needs review , turn on automatic site updates with a fairly frequent interval like 15 seconds, and then create at least one alert. Watch how all alerts are re-inserted to the DOM, even when they have not changed.
Use the "changed" timestamp field on alert entities to track what version of an alert was last rendered. If the timestamp matches between an existing alert DOM element and the latest alert data, do not replace/re-insert the alert markup.
No API changes specifically, but this would change the frontend behavior of the module. The event sitewide-alert-rendered will currently fire for every alert still present whenever an automatic refresh occurs. With this change, the event would only fire if the alert was not previously rendered or if it is updated to a newer version with a more recent timestamp.
Needs review
2.0
Code