I am creating a rather large AJAX-enabled site and using Prototype as my main framework. Everything was fine but recently I stumbled upon some VERY weird behavior. In this block of code:
[CODE]
#1: if (typeof x == ‘object’) {
#2: if (typeof x.activate == ‘function’)
#3: x.activate();
#4:
#5: Event.stop(e);
#6: }
What happens is that execution seems to skip from line #1 to line #5, even when the initial if fails! For example, if x is undefined, then the if condition will obviously fail, and execution should jump to after line #6. Instead, it goes inside the if, completely skips lines #2 and #3, and goes to line #5.
I wish I could show you the rest of the code, but it’s pretty complex and I don’t think it would show much. I can’t see anything wrong in this code or any of the surrounding code. This function that I show above, btw, is called by Prototype’s Event.observe() function. So, unless there is some bug with Prototype’s observe function, I can’t for the life of me understand this.
Has anyone ever had anything similar happen to them?