This is an isssue I found when I was building tfes tests. If we have multi observers on the same elements, then only the callback function of the first observer will be fired. Originally, I had this check:
for (var j=0,jc=elements.length;j<jc;j++)
{
// Skip observed elements
if (elements[j]._observed)
{
continue;
}
elements[j]._observed = true;
listener.fn(elements[j]);
}
Now I fixed it by assign an index to each observer and using it to check if an element is observed:
for (var j=0,jc=elements.length;j<jc;j++)
{
// Skip observed elements
if (elements[j]['_observed' + listener.index])
{
continue;
}
elements[j]['_observed' + listener.index] = true;
listener.fn(elements[j]);
}
This is an isssue I found when I was building tfes tests. If we have multi observers on the same elements, then only the callback function of the first observer will be fired. Originally, I had this check:
Now I fixed it by assign an
index
to each observer and using it to check if an element is observed: