mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-06 03:13:42 -05:00
Add guard against elements removed from the DOM
We can't guarantee that elements we stored a reference to with `classesToPersist.remove` will still exist so we need to guard against this. Note: it checks for whether the node is still attached to the DOM rather than whether it exists because the standard way to delete a node just detaches it from the DOM and relies on garbage collection to delete it from memory.
This commit is contained in:
@@ -26,7 +26,11 @@
|
||||
},
|
||||
replace: function () {
|
||||
this.classNames.forEach((className, index) => {
|
||||
this.$els[index].addClass(className);
|
||||
var $el = this.$els[index];
|
||||
|
||||
if (global.document.body.contains($el.get(0))) {
|
||||
$el.addClass(className);
|
||||
}
|
||||
});
|
||||
|
||||
// remove references to elements
|
||||
|
||||
Reference in New Issue
Block a user