Last active
November 18, 2019 13:55
-
-
Save gsmartagence/0a34036e782b3a977a3a222ed406e8fa 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
| /** | |
| * inline svg store | |
| * https://github.com/w0rm/gulp-svgstore#user-content-using-svg-as-external-file | |
| */ | |
| export const inlineSvgStore = (function (doc) { | |
| 'use strict' | |
| const iconPath = doc.getElementById('iconPath').dataset.path | |
| const scripts = doc.getElementsByTagName('script') | |
| const script = scripts[scripts.length - 1] | |
| const xhr = new XMLHttpRequest() | |
| xhr.onload = function () { | |
| var div = doc.createElement('div') | |
| div.innerHTML = this.responseText | |
| div.style.width = 0 | |
| div.style.height = 0 | |
| div.classList.add('visually-hidden') | |
| div.setAttribute('aria-hidden', true) | |
| script.parentNode.insertBefore(div, script) | |
| } | |
| xhr.open('get', iconPath, true) | |
| xhr.send() | |
| }(document)) |
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
| { | |
| "name": "inlineSvgStore.js", | |
| "version": "0.1.1" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment