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

Commit

Permalink
Fix IE9 incompatible classList JS
Browse files Browse the repository at this point in the history
Additionally add a check for whether the class has already been applied, so that (e.g., on page resize) the class doesn't get infinitely appended
  • Loading branch information
cee-chen committed Apr 24, 2017
1 parent d8a9a8f commit a5cbef3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/objectFitPolyfill.basic.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 dist/objectFitPolyfill.min.js

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

5 changes: 4 additions & 1 deletion src/objectFitPolyfill.basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@
$container.style.height = "100%";
}

$container.classList.add("object-fit-polyfill");
// Add a CSS class hook, in case people need to override styles for any reason.
if ($container.className.indexOf("object-fit-polyfill") === -1) {
$container.className = $container.className + " object-fit-polyfill";
}
};

/**
Expand Down
5 changes: 4 additions & 1 deletion src/objectFitPolyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@
$container.style.height = "100%";
}

$container.classList.add("object-fit-polyfill");
// Add a CSS class hook, in case people need to override styles for any reason.
if ($container.className.indexOf("object-fit-polyfill") === -1) {
$container.className = $container.className + " object-fit-polyfill";
}
};

/**
Expand Down

0 comments on commit a5cbef3

Please sign in to comment.