From: Dan Vanderkam Date: Mon, 13 Aug 2012 21:53:23 +0000 (-0400) Subject: Fix issue 322: calling destroy() results in an error in IE8 X-Git-Tag: v1.0.0~197 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=e276946939d737f58e904c94fa067e937a263d1e;p=dygraphs.git Fix issue 322: calling destroy() results in an error in IE8 --- diff --git a/dygraph-utils.js b/dygraph-utils.js index e942f0c..dd8c620 100644 --- a/dygraph-utils.js +++ b/dygraph-utils.js @@ -177,7 +177,12 @@ Dygraph.removeEvent = function addEvent(elem, type, fn) { if (elem.removeEventListener) { elem.removeEventListener(type, fn, false); } else { - elem.detachEvent('on'+type, elem[type+fn]); + try { + elem.detachEvent('on'+type, elem[type+fn]); + } catch(e) { + // We only detach event listeners on a "best effort" basis in IE. See: + // http://stackoverflow.com/questions/2553632/detachevent-not-working-with-named-inline-functions + } elem[type+fn] = null; } };