I just learned a hard lesson.
take a look at the following code.
salient.delegate.prototype.indexOf = function(fn)
{
/// <summary>
/// </summary>nbsp; {
for (var i = 0; i < this.eventHandlers.length; i++)
{
eventHandler = this.eventHandlers[i];
if (eventHandler.token === fn || eventHandler.fn === fn)
{
return i;
}
}
}
return -1;
}
and compare it to this
salient.delegate.prototype.indexOf = function(fn)
{
/// <summary>
/// </summary> if (this.eventHandlers && this.eventHandlers.length)
{
for (var i = 0; i < this.eventHandlers.length; i++)
{
if (this.eventHandlers[i].token === fn || this.eventHandlers[i].fn === fn)
{
return i;
}
}
}
return -1;
}
The first example does not find. The second does. Apparently indexing into an array dereferences the target.This wasn't one of those 3 hour hair pulling sessions, I was aware that I had just refactored that section and not being as fluent in javascript as I could be recognized that there may be a reference issue, because I know the function is in there, i just put it there and I know that previously I was matching. So - inlined the indexer and bingo. If it aint one thing it is another.... sheesh.