I have a mutation observer function:
function trackItemsSelected(elementId, Event) {
const targetNode = document.getElementById(elementId);
const config = { attributes: true, childList: true, subtree: true };
var removedItemCount = 0;
const callback = function (mutationsList) {
for (var mutation of mutationsList) {
if (mutation.type === 'childList') {
Event("item added");
}
if (mutation.type === 'attributes') {
removedItemCount += 1;
}
}
if (removedItemCount > 0) {
Event("item removed");
removedItemCount = 0;
}
};
const observer = new MutationObserver(callback);
observer.observe(targetNode, config);
}
My qunit tests are failing with the error 'Expected ';' on line 136 (which is this line: for (var mutation of mutationsList) {
However I cannot see where I am missing anything or any incorrect syntax? There are no errors showing in Visual Studio either. Can anyone see if there is an error I am missing with this function that might be causing the unit test failure?