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

Commit

Permalink
Add workaround for Edge 16 adding an incomplete version of object-fit
Browse files Browse the repository at this point in the history
Polyfill will now still work on video, but will skip <img> tags since that's what Edge 16 supports
  • Loading branch information
cee-chen committed Nov 10, 2017
1 parent baf3ef9 commit c632f2f
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
"test",
"tests"
],
"version": "2.0.5"
"version": "2.1.0"
}
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.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "objectFitPolyfill",
"version": "2.0.5",
"version": "2.1.0",
"description": "A Javascript polyfill for browsers that don't support the object-fit CSS property",
"main": "dist/objectFitPolyfill.min.js",
"keywords": [
Expand Down
7 changes: 5 additions & 2 deletions src/objectFitPolyfill.basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@
return;
}

// Workaround for Edge 16, which only implemented object-fit for <img> tags
var isEdge16 = ( window.navigator.userAgent.indexOf("Edge/16.") !== -1 );

// If the browser does support object-fit, we don't need to continue
if ("objectFit" in document.documentElement.style !== false) {
if ("objectFit" in document.documentElement.style !== false && !isEdge16) {
window.objectFitPolyfill = function() { return false };
return;
}
Expand Down Expand Up @@ -149,7 +152,7 @@
if (!media[i].nodeName) { continue; }
var mediaType = media[i].nodeName.toLowerCase();

if (mediaType === "img") {
if (mediaType === "img" && !isEdge16) {
if (media[i].complete) {
objectFit(media[i]);
}
Expand Down
7 changes: 5 additions & 2 deletions src/objectFitPolyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
return;
}

// Workaround for Edge 16, which only implemented object-fit for <img> tags
var isEdge16 = ( window.navigator.userAgent.indexOf("Edge/16.") !== -1 );

// If the browser does support object-fit, we don't need to continue
if ("objectFit" in document.documentElement.style !== false) {
if ("objectFit" in document.documentElement.style !== false && !isEdge16) {
window.objectFitPolyfill = function() { return false };
return;
}
Expand Down Expand Up @@ -246,7 +249,7 @@

var mediaType = media[i].nodeName.toLowerCase();

if (mediaType === "img") {
if (mediaType === "img" && !isEdge16) {
if (media[i].complete) {
objectFit(media[i]);
}
Expand Down

0 comments on commit c632f2f

Please sign in to comment.