From 2ca8c0d99975a0ef11e032eccae71dd7d79ade9c Mon Sep 17 00:00:00 2001
From: Brendan Dahl <brendan.dahl@gmail.com>
Date: Wed, 8 Aug 2012 09:07:31 -0700
Subject: [PATCH] Cleanup references to dom elements.

---
 src/canvas.js | 5 ++++-
 web/viewer.js | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/canvas.js b/src/canvas.js
index 058b57b7e..122dd5e59 100644
--- a/src/canvas.js
+++ b/src/canvas.js
@@ -1258,7 +1258,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
   return CanvasGraphics;
 })();
 
-if (!isWorker) {
+function checkPutBinaryImageDataCompatibility() {
   // Feature detection if the browser can use an Uint8Array directly as imgData.
   var canvas = document.createElement('canvas');
   canvas.width = 1;
@@ -1293,3 +1293,6 @@ if (!isWorker) {
       };
   }
 }
+if (!isWorker) {
+  checkPutBinaryImageDataCompatibility();
+}
diff --git a/web/viewer.js b/web/viewer.js
index a631bc004..b8118567c 100644
--- a/web/viewer.js
+++ b/web/viewer.js
@@ -1707,6 +1707,7 @@ var TextLayerBuilder = function textLayerBuilder(textLayerDiv) {
       if (textDivs.length === 0) {
         clearInterval(renderTimer);
         renderingDone = true;
+        self.textLayerDiv = textLayerDiv = canvas = ctx = null;
         return;
       }
       var textDiv = textDivs.shift();