svg-sprite-loader
Advanced tools
Comparing version 0.0.13 to 0.0.14
if ('angular' in window) { | ||
angular.module('ng').run(['$rootScope', '$window', function ($rootScope, $window) { | ||
angular.module('ng').run(['$rootScope', function ($rootScope) { | ||
$rootScope.$watch(function() { | ||
return $window.location.pathname + $window.location.search; | ||
}, function (newUrl, oldUrl) { | ||
if (newUrl === oldUrl) { | ||
return; | ||
} | ||
function dispatchLocationUpdateEvent(newUrl) { | ||
var evt = document.createEvent('CustomEvent'); | ||
@@ -16,4 +10,8 @@ evt.initCustomEvent('spriteLoaderLocationUpdated', false, false, { | ||
window.dispatchEvent(evt); | ||
} | ||
$rootScope.$on('$locationChangeSuccess', function (e, newUrl) { | ||
dispatchLocationUpdateEvent(newUrl); | ||
}); | ||
}]); | ||
} |
@@ -40,2 +40,12 @@ /** | ||
/** | ||
* Handles forbidden symbols which cannot be directly used inside attributes with url(...) content. | ||
* Adds leading slash for the brackets | ||
* @param url | ||
* @return encoded url | ||
*/ | ||
function encodeUrlForEmbedding(url) { | ||
return url.replace(/\(|\)/, "\\$&"); | ||
} | ||
/** | ||
* Replaces prefix in `url()` functions | ||
@@ -64,3 +74,4 @@ * @param {Element} svg | ||
if (match && match[1].indexOf(currentUrlPrefix) === 0) { | ||
node.setAttribute(attribute.localName, 'url(' + newUrlPrefix + match[1].split(currentUrlPrefix)[1] + ')'); | ||
var referenceUrl = encodeUrlForEmbedding(newUrlPrefix + match[1].split(currentUrlPrefix)[1]); | ||
node.setAttribute(attribute.localName, 'url(' + referenceUrl + ')'); | ||
} | ||
@@ -67,0 +78,0 @@ } |
{ | ||
"name": "svg-sprite-loader", | ||
"version": "0.0.13", | ||
"version": "0.0.14", | ||
"description": "SVG sprite webpack loader", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19565
432
117969