diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e6332c..ccc3392 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.1.8 (2017-04-18) + +- Added: Support for [custom attribute on `use` elements](https://github.com/jonathantneal/svg4everybody/pull/155) + ## 2.1.7 (2017-03-03) - Updated: Fixing internal use tag in polyfill diff --git a/dist/svg4everybody.js b/dist/svg4everybody.js index db1aacd..ec706aa 100644 --- a/dist/svg4everybody.js +++ b/dist/svg4everybody.js @@ -7,7 +7,7 @@ // like Node. module.exports = factory() : root.svg4everybody = factory(); }(this, function() { - /*! svg4everybody v2.1.7 | github.com/jonathantneal/svg4everybody */ + /*! svg4everybody v2.1.8 | github.com/jonathantneal/svg4everybody */ function embed(parent, svg, target) { // if the target exists if (target) { @@ -55,6 +55,7 @@ var use = uses[index], parent = use.parentNode, svg = getSVGAncestor(parent); if (svg) { var src = use.getAttribute("xlink:href") || use.getAttribute("href"); + !src && opts.attributeName && (src = use.getAttribute(opts.attributeName)); if (polyfill) { if (!opts.validate || opts.validate(src, svg, use)) { // remove the element diff --git a/dist/svg4everybody.legacy.js b/dist/svg4everybody.legacy.js index 3b3e4ce..a5b8ec5 100644 --- a/dist/svg4everybody.legacy.js +++ b/dist/svg4everybody.legacy.js @@ -7,7 +7,7 @@ // like Node. module.exports = factory() : root.svg4everybody = factory(); }(this, function() { - /*! svg4everybody v2.1.7 | github.com/jonathantneal/svg4everybody */ + /*! svg4everybody v2.1.8 | github.com/jonathantneal/svg4everybody */ function embed(parent, svg, target) { // if the target exists if (target) { @@ -56,7 +56,8 @@ if (svg) { var src = use.getAttribute("xlink:href") || use.getAttribute("href"); // if running with legacy support - if (nosvg) { + if (!src && opts.attributeName && (src = use.getAttribute(opts.attributeName)), + nosvg) { // create a new fallback image var img = document.createElement("img"); // force display in older IE diff --git a/dist/svg4everybody.legacy.min.js b/dist/svg4everybody.legacy.min.js index 6e4a7ef..197744e 100644 --- a/dist/svg4everybody.legacy.min.js +++ b/dist/svg4everybody.legacy.min.js @@ -1 +1 @@ -!function(a,b){"function"==typeof define&&define.amd?define([],function(){return a.svg4everybody=b()}):"object"==typeof module&&module.exports?module.exports=b():a.svg4everybody=b()}(this,function(){function a(a,b,c){if(c){var d=document.createDocumentFragment(),e=!b.hasAttribute("viewBox")&&c.getAttribute("viewBox");e&&b.setAttribute("viewBox",e);for(var f=c.cloneNode(!0);f.childNodes.length;)d.appendChild(f.firstChild);a.appendChild(d)}}function b(b){b.onreadystatechange=function(){if(4===b.readyState){var c=b._cachedDocument;c||(c=b._cachedDocument=document.implementation.createHTMLDocument(""),c.body.innerHTML=b.responseText,b._cachedTarget={}),b._embeds.splice(0).map(function(d){var e=b._cachedTarget[d.id];e||(e=b._cachedTarget[d.id]=c.getElementById(d.id)),a(d.parent,d.svg,e)})}},b.onreadystatechange()}function c(c){function e(){for(var c=0;c0)&&q(e,67)}var f,g,h=Object(c);g=h.fallback||function(a){return a.replace(/\?[^#]+/,"").replace("#",".").replace(/^\./,"")+".png"+(/\?[^#]+/.exec(a)||[""])[0]},f="nosvg"in h?h.nosvg:/\bMSIE [1-8]\b/.test(navigator.userAgent),f&&(document.createElement("svg"),document.createElement("use"));var i,j=/\bMSIE [1-8]\.0\b/,k=/\bTrident\/[567]\b|\bMSIE (?:9|10)\.0\b/,l=/\bAppleWebKit\/(\d+)\b/,m=/\bEdge\/12\.(\d+)\b/,n=/\bEdge\/.(\d+)\b/,o=window.top!==window.self;i="polyfill"in h?h.polyfill:j.test(navigator.userAgent)||k.test(navigator.userAgent)||(navigator.userAgent.match(m)||[])[1]<10547||(navigator.userAgent.match(l)||[])[1]<537||n.test(navigator.userAgent)&&o;var p={},q=window.requestAnimationFrame||setTimeout,r=document.getElementsByTagName("use"),s=0;i&&e()}function d(a){for(var b=a;"svg"!==b.nodeName.toLowerCase()&&(b=b.parentNode););return b}return c}); \ No newline at end of file +!function(a,b){"function"==typeof define&&define.amd?define([],function(){return a.svg4everybody=b()}):"object"==typeof module&&module.exports?module.exports=b():a.svg4everybody=b()}(this,function(){function a(a,b,c){if(c){var d=document.createDocumentFragment(),e=!b.hasAttribute("viewBox")&&c.getAttribute("viewBox");e&&b.setAttribute("viewBox",e);for(var f=c.cloneNode(!0);f.childNodes.length;)d.appendChild(f.firstChild);a.appendChild(d)}}function b(b){b.onreadystatechange=function(){if(4===b.readyState){var c=b._cachedDocument;c||(c=b._cachedDocument=document.implementation.createHTMLDocument(""),c.body.innerHTML=b.responseText,b._cachedTarget={}),b._embeds.splice(0).map(function(d){var e=b._cachedTarget[d.id];e||(e=b._cachedTarget[d.id]=c.getElementById(d.id)),a(d.parent,d.svg,e)})}},b.onreadystatechange()}function c(c){function e(){for(var c=0;c0)&&q(e,67)}var f,g,h=Object(c);g=h.fallback||function(a){return a.replace(/\?[^#]+/,"").replace("#",".").replace(/^\./,"")+".png"+(/\?[^#]+/.exec(a)||[""])[0]},f="nosvg"in h?h.nosvg:/\bMSIE [1-8]\b/.test(navigator.userAgent),f&&(document.createElement("svg"),document.createElement("use"));var i,j=/\bMSIE [1-8]\.0\b/,k=/\bTrident\/[567]\b|\bMSIE (?:9|10)\.0\b/,l=/\bAppleWebKit\/(\d+)\b/,m=/\bEdge\/12\.(\d+)\b/,n=/\bEdge\/.(\d+)\b/,o=window.top!==window.self;i="polyfill"in h?h.polyfill:j.test(navigator.userAgent)||k.test(navigator.userAgent)||(navigator.userAgent.match(m)||[])[1]<10547||(navigator.userAgent.match(l)||[])[1]<537||n.test(navigator.userAgent)&&o;var p={},q=window.requestAnimationFrame||setTimeout,r=document.getElementsByTagName("use"),s=0;i&&e()}function d(a){for(var b=a;"svg"!==b.nodeName.toLowerCase()&&(b=b.parentNode););return b}return c}); \ No newline at end of file diff --git a/dist/svg4everybody.min.js b/dist/svg4everybody.min.js index 812264b..20779c7 100644 --- a/dist/svg4everybody.min.js +++ b/dist/svg4everybody.min.js @@ -1 +1 @@ -!function(a,b){"function"==typeof define&&define.amd?define([],function(){return a.svg4everybody=b()}):"object"==typeof module&&module.exports?module.exports=b():a.svg4everybody=b()}(this,function(){function a(a,b,c){if(c){var d=document.createDocumentFragment(),e=!b.hasAttribute("viewBox")&&c.getAttribute("viewBox");e&&b.setAttribute("viewBox",e);for(var f=c.cloneNode(!0);f.childNodes.length;)d.appendChild(f.firstChild);a.appendChild(d)}}function b(b){b.onreadystatechange=function(){if(4===b.readyState){var c=b._cachedDocument;c||(c=b._cachedDocument=document.implementation.createHTMLDocument(""),c.body.innerHTML=b.responseText,b._cachedTarget={}),b._embeds.splice(0).map(function(d){var e=b._cachedTarget[d.id];e||(e=b._cachedTarget[d.id]=c.getElementById(d.id)),a(d.parent,d.svg,e)})}},b.onreadystatechange()}function c(c){function e(){for(var c=0;c0)&&n(e,67)}var f,g=Object(c),h=/\bTrident\/[567]\b|\bMSIE (?:9|10)\.0\b/,i=/\bAppleWebKit\/(\d+)\b/,j=/\bEdge\/12\.(\d+)\b/,k=/\bEdge\/.(\d+)\b/,l=window.top!==window.self;f="polyfill"in g?g.polyfill:h.test(navigator.userAgent)||(navigator.userAgent.match(j)||[])[1]<10547||(navigator.userAgent.match(i)||[])[1]<537||k.test(navigator.userAgent)&&l;var m={},n=window.requestAnimationFrame||setTimeout,o=document.getElementsByTagName("use"),p=0;f&&e()}function d(a){for(var b=a;"svg"!==b.nodeName.toLowerCase()&&(b=b.parentNode););return b}return c}); \ No newline at end of file +!function(a,b){"function"==typeof define&&define.amd?define([],function(){return a.svg4everybody=b()}):"object"==typeof module&&module.exports?module.exports=b():a.svg4everybody=b()}(this,function(){function a(a,b,c){if(c){var d=document.createDocumentFragment(),e=!b.hasAttribute("viewBox")&&c.getAttribute("viewBox");e&&b.setAttribute("viewBox",e);for(var f=c.cloneNode(!0);f.childNodes.length;)d.appendChild(f.firstChild);a.appendChild(d)}}function b(b){b.onreadystatechange=function(){if(4===b.readyState){var c=b._cachedDocument;c||(c=b._cachedDocument=document.implementation.createHTMLDocument(""),c.body.innerHTML=b.responseText,b._cachedTarget={}),b._embeds.splice(0).map(function(d){var e=b._cachedTarget[d.id];e||(e=b._cachedTarget[d.id]=c.getElementById(d.id)),a(d.parent,d.svg,e)})}},b.onreadystatechange()}function c(c){function e(){for(var c=0;c0)&&n(e,67)}var f,g=Object(c),h=/\bTrident\/[567]\b|\bMSIE (?:9|10)\.0\b/,i=/\bAppleWebKit\/(\d+)\b/,j=/\bEdge\/12\.(\d+)\b/,k=/\bEdge\/.(\d+)\b/,l=window.top!==window.self;f="polyfill"in g?g.polyfill:h.test(navigator.userAgent)||(navigator.userAgent.match(j)||[])[1]<10547||(navigator.userAgent.match(i)||[])[1]<537||k.test(navigator.userAgent)&&l;var m={},n=window.requestAnimationFrame||setTimeout,o=document.getElementsByTagName("use"),p=0;f&&e()}function d(a){for(var b=a;"svg"!==b.nodeName.toLowerCase()&&(b=b.parentNode););return b}return c}); \ No newline at end of file diff --git a/lib/svg4everybody.js b/lib/svg4everybody.js index 5cb1bf7..956275f 100644 --- a/lib/svg4everybody.js +++ b/lib/svg4everybody.js @@ -1,4 +1,4 @@ -/*! svg4everybody v2.1.7 | github.com/jonathantneal/svg4everybody */ +/*! svg4everybody v2.1.8 | github.com/jonathantneal/svg4everybody */ function embed(parent, svg, target) { // if the target exists diff --git a/package.json b/package.json index 5fa81ff..04a803a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "svg4everybody", - "version": "2.1.7", + "version": "2.1.8", "description": "Use external SVG spritemaps in any browser", "main": "dist/svg4everybody.js", "dependencies": {},