Handles cases where an alert message is being inserted into multiple containers.
Issue
When .notify.js
identifies the container to insert a message into, it can potentially select — and insert the message into — multiple containers.
Currently, all but the last one inserted are 'orphaned' and left behind — hidden— in the DOM. The reveal, and presumably subsequent dismissal, are not actioned on the other inserted messages.
This cropped up because I had two forms on a screen, one of them hidden, and had made a typo in the for="first_form"
attribute on the intended validation element. Because of that the messages were getting inserted for both forms, but only the one on the second form was revealed. Eventually tracked it down to this.
I think there's also a use case where you might genuinely want a validation message appear in two places, e.g. on a long form.
What I did
- When inserting the message element, the insertion result is now assigned back to
$message
before continuing.- This means that a single message will become multiple instances, if inserted multiple times, for the purposes of the following event logic.
Implications
None
Setup
None
How to test
- Code review.
- Test out on a screen with two forms and suitably misspelled or missing
for=xxx
attributes on the validation elements.