Skip to content
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.

Commit

Permalink
changed whitespace to match existing style, and added test case for p…
Browse files Browse the repository at this point in the history
…arentless srcset img element
  • Loading branch information
saranrapjs committed Feb 4, 2015
1 parent 0814979 commit 59566bf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dist/picturefill.js
Expand Up @@ -601,7 +601,7 @@ window.matchMedia || (window.matchMedia = function() {
}

// Cache and remove `srcset` if present and we’re going to be doing `picture`/`srcset`/`sizes` polyfilling to it.
if ( (parent && parent.nodeName.toUpperCase() === "PICTURE") ||
if ( ( parent && parent.nodeName.toUpperCase() === "PICTURE" ) ||
( element.srcset && !pf.srcsetSupported ) ||
( !pf.sizesSupported && ( element.srcset && element.srcset.indexOf("w") > -1 ) ) ) {
pf.dodgeSrcset( element );
Expand Down
2 changes: 1 addition & 1 deletion src/picturefill.js
Expand Up @@ -552,7 +552,7 @@
}

// Cache and remove `srcset` if present and we’re going to be doing `picture`/`srcset`/`sizes` polyfilling to it.
if ( (parent && parent.nodeName.toUpperCase() === "PICTURE") ||
if ( ( parent && parent.nodeName.toUpperCase() === "PICTURE" ) ||
( element.srcset && !pf.srcsetSupported ) ||
( !pf.sizesSupported && ( element.srcset && element.srcset.indexOf("w") > -1 ) ) ) {
pf.dodgeSrcset( element );
Expand Down
10 changes: 10 additions & 0 deletions tests/tests.js
Expand Up @@ -582,4 +582,14 @@

});

test( "`img` can be added outside the DOM without errors", function() {
var img = document.createElement( "img" );

img.setAttribute( "srcset", "data:img 500w" );

picturefill( { elements: [ img ] } );

assert.equal( img.currentSrc || img.src, "data:img" );
});

})( window, jQuery );

0 comments on commit 59566bf

Please sign in to comment.