Skip to content

Instantly share code, notes, and snippets.

@xperiments
Created October 9, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xperiments/6702078c46ee1ec5d039 to your computer and use it in GitHub Desktop.
Save xperiments/6702078c46ee1ec5d039 to your computer and use it in GitHub Desktop.
// Original: https://gist.github.com/leonderijke/c5cf7c5b2e424c0061d2
(function(document, window) {
"use strict";
document.addEventListener("DOMContentLoaded", function() {
var baseUrl = window.location.href
.replace(window.location.hash, "");
[].slice.call(document.querySelectorAll("use[*|href]"))
.filter(function(element) {
return (element.getAttribute("xlink:href").indexOf("#") === 0);
})
.forEach(function(element) {
element.setAttribute("xlink:href", baseUrl + element.getAttribute("xlink:href"));
});
[].slice.call(document.querySelectorAll("[clip-path]"))
.filter(function(element) {
return (element.getAttribute("clip-path").indexOf("url(#") === 0);
})
.forEach(function(element) {
element.setAttribute("clip-path", 'url('+ baseUrl + element.getAttribute("clip-path").replace(/url\((.*)\)/,'$1')+')');
});
}, false);
}(document, window));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment