diff options
author | Johann-S <johann.servoire@gmail.com> | 2020-03-18 14:10:55 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-18 14:10:55 +0300 |
commit | aff115219ee47b261b943bbe65cf5919fe021a22 (patch) | |
tree | cff50377c0c3fdaabf09fcdc7ee49327c2f6eaf2 /js/src/util | |
parent | d773cafe3dacee19639ec7b523fb9b4c89ec0129 (diff) |
fix: ensure `totype` always returns stringified null/undefined when null/undefined is passed (#30383)
Diffstat (limited to 'js/src/util')
-rw-r--r-- | js/src/util/index.js | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/js/src/util/index.js b/js/src/util/index.js index 8a5ae21566..fca2a91977 100644 --- a/js/src/util/index.js +++ b/js/src/util/index.js @@ -10,7 +10,13 @@ const MILLISECONDS_MULTIPLIER = 1000 const TRANSITION_END = 'transitionend' // Shoutout AngusCroll (https://goo.gl/pxwQGp) -const toType = obj => ({}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase()) +const toType = obj => { + if (obj === null || obj === undefined) { + return `${obj}` + } + + return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase() +} /** * -------------------------------------------------------------------------- |