Created
November 7, 2018 04:42
-
-
Save dhwang/2fdd51375762b3bfc52c971fa127ae28 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import _ from 'lodash'; | |
/** | |
* Check to see if a particular SVG tag is supported in the browser. | |
* <code> console.log('foreignObject', canUseSVG('foreignObject')); </code> | |
* @returns Boolean | |
*/ | |
export const canUseSVG = (tagStr) => { | |
if (!_.isEmpty(tagStr)) { | |
const lowerCaseTag = tagStr.toLowerCase(); | |
return document.createElementNS('http://www.w3.org/2000/svg', tagStr) | |
.toString() | |
.toLowerCase() | |
.indexOf(lowerCaseTag) !== -1; | |
} | |
return false; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment