From e276946939d737f58e904c94fa067e937a263d1e Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Mon, 13 Aug 2012 17:53:23 -0400 Subject: [PATCH] Fix issue 322: calling destroy() results in an error in IE8 --- dygraph-utils.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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; } }; -- 2.7.4