12345678910111213141516171819 |
- /**
- * @param {string} content
- * @return {Element}
- */
- export default function (content) {
- const hasImportNode = !!document.importNode;
- const doc = new DOMParser().parseFromString(content, 'image/svg+xml').documentElement;
- /**
- * Fix for browser which are throwing WrongDocumentError
- * if you insert an element which is not part of the document
- * @see http://stackoverflow.com/a/7986519/4624403
- */
- if (hasImportNode) {
- return document.importNode(doc, true);
- }
- return doc;
- }
|