Ticket #64 (closed defect: wontfix)
Fix map viewer red reset button in IE
| Reported by: | rjwalker | Owned by: | mcoudert |
|---|---|---|---|
| Priority: | minor | Milestone: | v2.6.0 RC0 |
| Component: | Web Map Viewer | Version: | v2.2.0 Final |
| Keywords: | Cc: |
Description
- Start up GN in IE7.
- Click on "Open Map Viewer".
- Click on the red and white reset (on/off) button at the top right of the big map.
- Scroll to the bottom of the page and observe the error message: "Exception 'Object doesn't support this property or method'".
It seems this was broken by the cleanup of Intermap in revision 955.
The Intermap.rebuild() function is not an event handler, so one shouldn't use bindAsEventListener() on it. This time it is just "good luck" that the code works in Firefox.
I attach a patch.
[The reason the existing code works on Firefox and not in IE is because of the implementation of bindAsEventListener() in prototype.js.
The second time rebuild() is called (after pressing the red reset button), it is being called by bindAsEventListener(), and bindAsEventListener() is passing the value of window.event as the parameter to rebuild(). IE has window.event; Firefox doesn't, so the value of "window.event" is undefined.
It is possible to see this difference "in action".
In IE, use Script Debugger to set a breakpoint inside the body of rebuild(). After pressing the red reset button, the breakpoint is reached the first time with the parameter "callback" set to a function. The second time the breakpoint is reached, the parameter "callback" is set to an event. Thus the subsequent call to callback() generates an exception.
Now do the same think in Firefox using Firebug. The second time the breakpoint is reached, the parameter "callback" is undefined, and thus not invoked as a function.
And yes, although the fix is trivial, this took me a very long time to figure out - but at least I learnt quite a lot along the way.]
Index: web/intermap/scripts/im_integration.js
===================================================================
--- web/intermap/scripts/im_integration.js (revision 1335)
+++ web/intermap/scripts/im_integration.js (working copy)
@@ -267,7 +267,7 @@
im_bm.setBBox_dom(req.responseXML);
im_mm.setBBox_dom(req.responseXML);
- im_bm.rebuild(im_mm.rebuild.bindAsEventListener(im_mm));
+ im_bm.rebuild(im_mm.rebuild.bind(im_mm));
// TODO: reset AoI also?
}
