Permalink
Browse files

if no sources match upon assessment, no image should be shown. Fixes #11

  • Loading branch information...
1 parent 404c39d commit a0a2a128d6593f792e86d4c9b8333a04d852dc2e scottjehl committed Apr 23, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 picturefill.js
View
@@ -45,9 +45,10 @@
}
}
+ // Find any existing img element in the picture element
+ var picImg = ps[ i ].getElementsByTagName( "img" )[ 0 ];
+
if( matches.length ){
- // Set fallback img element src from that of last matching source element
- var picImg = ps[ i ].getElementsByTagName( "img" )[ 0 ];
if( !picImg ){
picImg = w.document.createElement( "img" );
@@ -57,6 +58,9 @@
picImg.src = matches.pop().getAttribute( "src" );
}
+ else if( picImg ) {
+ ps[ i ].removeChild( picImg );
+ }
}
};

0 comments on commit a0a2a12

Please sign in to comment.