Deal with elements no longer in the DOM

Instead of keeping references to nodes detached
from the DOM, remove them from the store.
Likewise, add node appended to the DOM.

This includes code to 'clean' DOM nodes when
removed. This is important because nodes can
retain classes and styles. If they are re-attached
in future this can cause problems with how the
state of the element is determined.
This commit is contained in:
Tom Byers
2019-01-10 17:29:41 +00:00
parent 03e38dfdef
commit a6a7057d64
2 changed files with 37 additions and 10 deletions

View File

@@ -13,9 +13,7 @@
this.$stickyBottom = this.$form.find('#sticky_template_forms');
this.$stickyBottom.append(this.nothingSelectedButtons);
GOVUK.stickAtBottomWhenScrolling.add(this.nothingSelectedButtons, true);
this.$stickyBottom.append(this.itemsSelectedButtons);
GOVUK.stickAtBottomWhenScrolling.add(this.itemsSelectedButtons, true);
// all the diff states that we want to show or hide
this.states = [