Skip to content

Commit

Permalink
Merge pull request scottjehl#484 from scottjehl/2.3
Browse files Browse the repository at this point in the history
2.3.1 (from 2.3)
  • Loading branch information
Wilto committed Apr 9, 2015
2 parents c54b0a8 + 8bc1c7b commit a8c2c6f
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 21 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "picturefill",
"repo": "scottjehl/picturefill",
"description": "A Polyfill for the HTML Picture Element (http://picture.responsiveimages.org/) that you can use today.",
"version": "2.3.0",
"version": "2.3.1",
"main": "dist/picturefill.js",
"scripts": [
"dist/picturefill.js"
Expand Down
23 changes: 11 additions & 12 deletions dist/picturefill.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Picturefill - v2.3.0 - 2015-03-23
/*! Picturefill - v2.3.1 - 2015-04-09
* http://scottjehl.github.io/picturefill
* Copyright (c) 2015 https://github.com/scottjehl/picturefill/blob/master/Authors.txt; Licensed MIT */
/*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas, David Knight. Dual MIT/BSD license */
Expand Down Expand Up @@ -92,6 +92,7 @@ window.matchMedia || (window.matchMedia = function() {
(function() {
pf.srcsetSupported = "srcset" in image;
pf.sizesSupported = "sizes" in image;
pf.curSrcSupported = "currentSrc" in image;
})();

// just a string trim workaround
Expand Down Expand Up @@ -504,7 +505,9 @@ window.matchMedia || (window.matchMedia = function() {
picImg.src = bestCandidate.url;
// currentSrc attribute and property to match
// http://picture.responsiveimages.org/#the-img-element
picImg.currentSrc = picImg.src;
if ( !pf.curSrcSupported ) {
picImg.currentSrc = picImg.src;
}

pf.backfaceVisibilityFix( picImg );
}
Expand Down Expand Up @@ -707,17 +710,13 @@ window.matchMedia || (window.matchMedia = function() {
}
}, 250 );

var resizeTimer;
var handleResize = function() {
picturefill({ reevaluate: true });
};
function checkResize() {
var resizeThrottle;

if ( !w._picturefillWorking ) {
w._picturefillWorking = true;
w.clearTimeout( resizeThrottle );
resizeThrottle = w.setTimeout( function() {
picturefill({ reevaluate: true });
w._picturefillWorking = false;
}, 60 );
}
clearTimeout(resizeTimer);
resizeTimer = setTimeout( handleResize, 60 );
}

if ( w.addEventListener ) {
Expand Down
4 changes: 2 additions & 2 deletions dist/picturefill.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 package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "picturefill",
"description": "A responsive image polyfill.",
"version": "2.3.0",
"version": "2.3.1",
"homepage": "https://scottjehl.github.io/picturefill/",
"bugs": "https://github.com/scottjehl/picturefill/issues",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion picturefill.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Picturefill",
"title": "Picturefill",
"description": "A Polyfill for the HTML Picture Element (http://picture.responsiveimages.org/) that you can use today.",
"version": "2.3.0",
"version": "2.3.1",
"homepage": "http://scottjehl.github.io/picturefill",
"author": {
"name": "https://github.com/scottjehl/picturefill/blob/master/Authors.txt",
Expand Down
5 changes: 4 additions & 1 deletion src/picturefill.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
(function() {
pf.srcsetSupported = "srcset" in image;
pf.sizesSupported = "sizes" in image;
pf.curSrcSupported = "currentSrc" in image;
})();

// just a string trim workaround
Expand Down Expand Up @@ -455,7 +456,9 @@
picImg.src = bestCandidate.url;
// currentSrc attribute and property to match
// http://picture.responsiveimages.org/#the-img-element
picImg.currentSrc = picImg.src;
if ( !pf.curSrcSupported ) {
picImg.currentSrc = picImg.src;
}

pf.backfaceVisibilityFix( picImg );
}
Expand Down
10 changes: 7 additions & 3 deletions tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,15 +461,19 @@
pf.applyBestCandidate( candidates, image );

deepEqual(image.src, candidates[2].url, "uses the url from the best px fit" );
deepEqual(image.currentSrc, candidates[2].url, "uses the url from the best px fit" );
if ( !pf.curSrcSupported ) {
deepEqual(image.currentSrc, candidates[2].url, "uses the url from the best px fit" );
}

image.src = "data:300";
image.currentSrc = "data:300";

pf.applyBestCandidate( candidates, image );

deepEqual(image.src, "data:300", "src left alone when matched" );
deepEqual(image.currentSrc, "data:300", "currentSrc left alone when matched" );
if ( !pf.curSrcSupported ) {
deepEqual(image.currentSrc, "data:300", "currentSrc left alone when matched" );
}
});

test( "removeVideoShim", function() {
Expand Down Expand Up @@ -612,7 +616,7 @@

picturefill( { elements: [ img ] } );

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

})( window, jQuery );

0 comments on commit a8c2c6f

Please sign in to comment.