From 57aff81777c10aa36d7ba538f29c6c9118e50a45 Mon Sep 17 00:00:00 2001 From: Mohamad Jahani Date: Fri, 25 Sep 2015 20:52:03 +0330 Subject: [PATCH] check single element type to be html image element --- snaphash.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/snaphash.js b/snaphash.js index cd2cac0..b525001 100644 --- a/snaphash.js +++ b/snaphash.js @@ -8,13 +8,13 @@ } // selector provided - if (typeof els === 'string') { + else if (typeof els === 'string') { els = document.querySelectorAll(els); } - // single element provided - if (typeof els.length === 'undefined') { - els = [els]; + // single element provided (only image element) + else if (!els instanceof HTMLImageElement) { + throw TypeError("Can not apply Snaphash to " + els.constructor.name + " type. You must provide an image element/selector"); } // loop over elements -- 2.34.1