Skip to content

Commit

Permalink
check if src is undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
timeiscoffee committed Jul 20, 2017
1 parent 377d272 commit 3850089
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 16 deletions.
7 changes: 3 additions & 4 deletions dist/svg4everybody.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@
for (// get the cached <use> index
var index = 0; index < uses.length; ) {
// get the current <use>
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));
var use = uses[index], parent = use.parentNode, svg = getSVGAncestor(parent), src = use.getAttribute("xlink:href") || use.getAttribute("href");
if (!src && opts.attributeName && (src = use.getAttribute(opts.attributeName)),
svg && src) {
if (polyfill) {
if (!opts.validate || opts.validate(src, svg, use)) {
// remove the <use> element
Expand Down
9 changes: 4 additions & 5 deletions dist/svg4everybody.legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,11 @@
for (// get the cached <use> index
var index = 0; index < uses.length; ) {
// get the current <use>
var use = uses[index], parent = use.parentNode, svg = getSVGAncestor(parent);
if (svg) {
var src = use.getAttribute("xlink:href") || use.getAttribute("href");
var use = uses[index], parent = use.parentNode, svg = getSVGAncestor(parent), src = use.getAttribute("xlink:href") || use.getAttribute("href");
if (!src && opts.attributeName && (src = use.getAttribute(opts.attributeName)),
svg && src) {
// if running with legacy support
if (!src && opts.attributeName && (src = use.getAttribute(opts.attributeName)),
nosvg) {
if (nosvg) {
// create a new fallback image
var img = document.createElement("img");
// force display in older IE
Expand Down
2 changes: 1 addition & 1 deletion dist/svg4everybody.legacy.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/svg4everybody.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions lib/svg4everybody.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ function svg4everybody(rawopts) {
// get the current <svg>
var parent = use.parentNode;
var svg = getSVGAncestor(parent);
var src = use.getAttribute('xlink:href') || use.getAttribute('href');

if (svg) {
var src = use.getAttribute('xlink:href') || use.getAttribute('href');
if (!src && opts.attributeName) {
src = use.getAttribute(opts.attributeName);
}

if (!src && opts.attributeName) {
src = use.getAttribute(opts.attributeName);
}
if (svg && src) {

// if running with legacy support
if (LEGACY_SUPPORT && nosvg) {
Expand Down

0 comments on commit 3850089

Please sign in to comment.