In version v0.7.3, the destroyAllMessages function is defined like this :
this.destroyAllMessages = function (referenceId) {
var messages = this.getAllMessages(referenceId), i = messages.length;
for (i - 1; i >= 0; i--) {
messages[i].destroy();
}
if (this.directives[referenceId]) {
this.directives[referenceId].messages = [];
}
};
On the first loop, notice the i - 1 statement which does nothing. Calling this method on an empty messages array will iterate one time and will raise an exception because messages[0] returns undefined.
I propose the following version :
this.destroyAllMessages = function (referenceId) {
var messages = this.getAllMessages(referenceId);
for (var i = messages.length - 1; i >= 0; i--) {
messages[i].destroy();
}
if (this.directives[referenceId]) {
this.directives[referenceId].messages = [];
}
};
In version v0.7.3, the
destroyAllMessages
function is defined like this :On the first loop, notice the
i - 1
statement which does nothing. Calling this method on an empty messages array will iterate one time and will raise an exception becausemessages[0]
returnsundefined
.I propose the following version :