this.foo.bar, would evaluate it, if a complex variable such as that exists in the supplied context, or just return the string if it does not. It does this lookup by evaluating each piece with an array lookup. In this example, the first step would be to perform,
This code works pretty well in Safari and Firefox, but in IE6, I got this strange error that just didn’t make any sense. For some reason, the symbol lookup code was changing the string ‘5’ to the window object. What I really couldn’t understand was why removing the Appcelerator Calendar widget fixed the problem.
The supplied context to my variable lookup guy was
window. Of course,
window doesn’t mean anything. But Wait! IE6 returns something that looks an awful lot like the
window object. On a whim, I tried,
window which returned
undefined, which is what I was expecting in the first place. Then I looked a little harder at the DOM that resulted from the widget and noticed
<iframe> tags. I had 5 of these widgets, which would explain why windows 0-5 weren’t
undefined. If the value I was trying to test this code on wasn’t 2, I would have never seen this.
In the end, my fix was, if the value to lookup looks like a number, assume the person wants a number. As is normally the cause with debugging, 5 hours of work results in a 3 line change.
Did you like this? Please share:
The Lost Year: A Failed Experiment to Switch Away From Mac
Fed up with the Apple Keyboard, I bought a ThinkPad, installed Linux, and promptly decided that I hated computers.
Maker's Space, Manager's Space
The Grand Remote Work Experiment: A Retrospective
The COVID-19 pandemic has lead to an unexpected experiment in remote working. What has worked and why?