Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

Commit

Permalink
Minor tweaks found while writing tests
Browse files Browse the repository at this point in the history
- Add test coverage ignore for missing axis else branch - it's not reachable normally, but it's there as a safety catch in case we ever misuse setPosition

- Fix parseInt that's missing a base10 radix

- Fix docblock comment with incorrect example params
  • Loading branch information
cee-chen committed Jan 28, 2021
1 parent e4698d6 commit 986c2a2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/objectFitPolyfill.min.js

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

5 changes: 3 additions & 2 deletions src/objectFitPolyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
*
* @param {string} axis - either "x" or "y"
* @param {node} $media - img or video element
* @param {string} objectPosition - e.g. "50% 50%", "top bottom"
* @param {string} objectPosition - e.g. "50% 50%", "top left"
*/
var setPosition = function(axis, $media, objectPosition) {
var position, other, start, end, side;
Expand All @@ -109,6 +109,7 @@
objectPosition[1] = objectPosition[0];
}

/* istanbul ignore else */
if (axis === 'x') {
position = objectPosition[0];
other = objectPosition[1];
Expand Down Expand Up @@ -143,7 +144,7 @@

// Percentage values (e.g., 30% 10%)
if (position.indexOf('%') >= 0) {
position = parseInt(position);
position = parseInt(position, 10);

if (position < 50) {
$media.style[start] = position + '%';
Expand Down

0 comments on commit 986c2a2

Please sign in to comment.