From 0c662b8a8d1e414e0e44c5e0a48e9a04ed4123e6 Mon Sep 17 00:00:00 2001 From: Luke Murray Date: Mon, 12 Aug 2013 16:38:37 +1000 Subject: [PATCH] fix: comment updates and add a simple test for viewer.destroy --- src/eventhandler.js | 3 ++- src/mousetracker.js | 2 +- src/viewer.js | 3 ++- test/basic.js | 25 +++++++++++++++++++++++++ 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/eventhandler.js b/src/eventhandler.js index b834b214..f82a55b3 100644 --- a/src/eventhandler.js +++ b/src/eventhandler.js @@ -91,7 +91,8 @@ $.EventHandler.prototype = { /** - * Remove all event handler for a given event type. If no type is given all event handlers for every event type is removed + * Remove all event handlers for a given event type. If no type is given all + * event handlers for every event type is removed. * @function * @param {String} eventName - Name of event for which all handlers are to be removed. */ diff --git a/src/mousetracker.js b/src/mousetracker.js index 1b4de92d..dccea7c5 100644 --- a/src/mousetracker.js +++ b/src/mousetracker.js @@ -172,7 +172,7 @@ $.MouseTracker.prototype = { /** - * Clean up any events or objects created the mouse tracker + * Clean up any events or objects created by the mouse tracker. * @function */ destroy: function() { diff --git a/src/viewer.js b/src/viewer.js index d3dd7579..d9b02708 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -513,7 +513,8 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype, /** - * Function to destroy the viewer and clean up everything created by Open Seadragon + * Function to destroy the viewer and clean up everything created by + * OpenSeadragon. * @function * @name OpenSeadragon.Viewer.prototype.destroy */ diff --git a/test/basic.js b/test/basic.js index 61f36673..f83d7c80 100644 --- a/test/basic.js +++ b/test/basic.js @@ -208,4 +208,29 @@ viewer.open('/test/data/testpattern.dzi'); }); + // ---------- + asyncTest('Destroy', function() { + viewer.addHandler("open", function () { + start(); + // Check that the DOM has been modified + notEqual(0, $('#example').children().length); + + var closeHandler = function() { + viewer.removeHandler('close', closeHandler); + ok(true, 'Close event was sent on Destroy'); + }; + + viewer.addHandler('close', closeHandler); + viewer.destroy(); + + // Check that the DOM has been cleaned up + equal(0, $('#example').children().length); + equal(null, viewer.canvas); + equal(null, viewer.keyboardCommandArea); + equal(null, viewer.container); + equal(null, viewer.element); + }); + viewer.open('/test/data/testpattern.dzi'); + }); + })();