highslide-software/highcharts.com — pull request #2429 by teppeis (2013-11-05 13:01:52+00:00)
Title: Legacy IE event handling issue of standalone-framework adaptor

In standalone-framework adaptor, legacy IE cannot unbind event handlers in some case.

It use `fn.toString()` as a key of proxied handler caching.

```javascript
/// in bind
el.HCProxiedMethods[fn.toString()] = wrappedFn;

/// in unbind
function IERemoveOneEvent(el, type, fn) {
fn = el.HCProxiedMethods[fn.toString()];
el.detachEvent('on' + type, fn);
}
```

But different handlers can return same value for `toString()`.

For example: Parts#setDOMEvents()
```javascript
setDOMEvents: function () {
var pointer = this,
container = pointer.chart.container,
events;

this._events = events = [
[container, 'onmousedown', 'onContainerMouseDown'],
[container, 'onmousemove', 'onContainerMouseMove'],
[container, 'onclick', 'onContainerClick'],
[container, 'mouseleave', 'onContainerMouseLeave'],
[doc, 'mousemove', 'onDocumentMouseMove'],
[doc, 'mouseup', 'onDocumentMouseUp']
];

// ...

each(events, function (eventConfig) {
pointer['_' + eventConfig[2]] = function (e) {
pointer[eventConfig[2]](e);
};

if (eventConfig[1].indexOf('on') === 0) {
eventConfig[0][eventConfig[1]] = pointer['_' + eventConfig[2]];
} else {
addEvent(eventConfig[0], eventConfig[1], pointer['_' + eventConfig[2]]);
}
});
},
```

In the above, every `pointer['_' + eventConfig[2]].toString()` (3rd arg of `addEvent()`) is:
```
function (e) {
pointer[eventConfig[2]](e);
};
```
So `document.HCProxiedMethods[fn.toString()]` of mouseup overwrites previous one (=mousemove handler).

As a result, after init and destroy Pointer, the mousemove handler remains.
And if multiple Pointers are initialized, many mousemove and mouseup handlers remain.
The mouseup handler occurs JS error: http://jsfiddle.net/teppeis/qQB22/
(iframe src: http://fiddle.jshell.net/teppeis/qQB22/show/light/)

----

To fix it, I used `handlerId` counter as the key of proxied handlers like `guid` of jQuery.