From ad1fc0e48d18b40ed2f94ec41c0d595e882573a7 Mon Sep 17 00:00:00 2001 From: josephj Date: Mon, 4 Apr 2016 22:24:55 +1000 Subject: [PATCH] Validate the first argument of parse method The first argument type of `parse` method can only be of `String` or `HTML Element`. --- 2/twemoji.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/2/twemoji.js b/2/twemoji.js index a1bf9c5f..73d68083 100644 --- a/2/twemoji.js +++ b/2/twemoji.js @@ -515,6 +515,14 @@ var twemoji = (function ( } function parse(what, how) { + // first argument can only be string or HTML Element + if ( + typeof what !== 'string' && + !(what && what.nodeName) + ) { + return what; + } + if (!how || typeof how === 'function') { how = {callback: how}; } @@ -563,4 +571,4 @@ var twemoji = (function ( return r.join(sep || '-'); } -}()); \ No newline at end of file +}());