jgraph / mxgraph

mxGraph is a fully client side JavaScript diagramming library
Other
6.79k stars 2.06k forks source link

mxKeyHandler.destroy leaves junk DOM event handler. #20

Closed yaliashkevich closed 11 years ago

yaliashkevich commented 11 years ago
var original = mxKeyHandler.prototype.keyDown;
mxKeyHandler.prototype.keyDown = function () {
    alert('internal handler callback');
    original.apply(this, arguments);
};

var graph = new mxGraph(container);
var handler = new mxKeyHandler(graph);
handler.bindKey('65', function () { alert('I am active'); });
handler.destroy();

Assume that mxKeyHandler.prototype.keyDown handler should be removed on destroy:

mxKeyHandler.prototype.destroy = function()
{
    mxEvent.removeListener(this.target, 'keydown' ... )
}

That's not critical but if you create and destroy key handlers dynamically during page life cycle a lot of junk handlers occupy browser resources.

alderg commented 11 years ago

Thanks for the report, this will be fixed in the next release.