From a921953d1ac28297e107f19f093d7f9765895658 Mon Sep 17 00:00:00 2001 From: Lokesh Dhakar Date: Sun, 26 May 2019 20:31:37 -0700 Subject: [PATCH] refactor: Don't append canvas to DOM --- src/color-thief.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/color-thief.js b/src/color-thief.js index 3092e5d..77ddc28 100644 --- a/src/color-thief.js +++ b/src/color-thief.js @@ -28,8 +28,6 @@ var CanvasImage = function (image) { this.canvas = document.createElement('canvas'); this.context = this.canvas.getContext('2d'); - document.body.appendChild(this.canvas); - this.width = this.canvas.width = image.width; this.height = this.canvas.height = image.height; @@ -44,11 +42,6 @@ CanvasImage.prototype.getImageData = function () { return this.context.getImageData(0, 0, this.width, this.height); }; -CanvasImage.prototype.removeCanvas = function () { - this.canvas.parentNode.removeChild(this.canvas); -}; - - var ColorThief = function () {}; /* @@ -124,9 +117,6 @@ ColorThief.prototype.getPalette = function(sourceImage, colorCount, quality) { var cmap = MMCQ.quantize(pixelArray, colorCount); var palette = cmap? cmap.palette() : null; - // Clean up - image.removeCanvas(); - return palette; };