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

Commit

Permalink
fixed incorrect looping from length + 1 to length in parse descriptor…
Browse files Browse the repository at this point in the history
…, and removed unnecessary undefined check
  • Loading branch information
lab49dsun committed Oct 4, 2014
1 parent 80573aa commit c409c9d
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/picturefill.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,17 +263,15 @@
if ( sizeDescriptor ) {
var splitDescriptor = sizeDescriptor.split(" ");

for (var i = splitDescriptor.length + 1; i >= 0; i--) {
if ( splitDescriptor[ i ] !== undefined ) {
var curr = splitDescriptor[ i ],
lastchar = curr && curr.slice( curr.length - 1 );

if ( ( lastchar === "h" || lastchar === "w" ) && !pf.sizesSupported ) {
resCandidate = parseFloat( ( parseInt( curr, 10 ) / widthInCssPixels ) );
} else if ( lastchar === "x" ) {
var res = curr && parseFloat( curr, 10 );
resCandidate = res && !isNaN( res ) ? res : 1;
}
for (var i = splitDescriptor.length - 1; i >= 0; i--) {
var curr = splitDescriptor[ i ],
lastchar = curr && curr.slice( curr.length - 1 );

if ( ( lastchar === "h" || lastchar === "w" ) && !pf.sizesSupported ) {
resCandidate = parseFloat( ( parseInt( curr, 10 ) / widthInCssPixels ) );
} else if ( lastchar === "x" ) {
var res = curr && parseFloat( curr, 10 );
resCandidate = res && !isNaN( res ) ? res : 1;
}
}
}
Expand Down

0 comments on commit c409c9d

Please sign in to comment.