Skip to content

Commit

Permalink
polyfills for IE11 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
gassc committed Nov 21, 2017
1 parent 16aebbc commit 009b63e
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
56 changes: 56 additions & 0 deletions project/static/js/backCompat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* enable compatibility with our TurfJS 5 build and IE11
*/
if (!Array.prototype.fill) {
Object.defineProperty(Array.prototype, 'fill', {
value: function(value) {

// Steps 1-2.
if (this == null) {
throw new TypeError('this is null or not defined');
}

var O = Object(this);

// Steps 3-5.
var len = O.length >>> 0;

// Steps 6-7.
var start = arguments[1];
var relativeStart = start >> 0;

// Step 8.
var k = relativeStart < 0 ?
Math.max(len + relativeStart, 0) :
Math.min(relativeStart, len);

// Steps 9-10.
var end = arguments[2];
var relativeEnd = end === undefined ?
len : end >> 0;

// Step 11.
var final = relativeEnd < 0 ?
Math.max(len + relativeEnd, 0) :
Math.min(relativeEnd, len);

// Step 12.
while (k < final) {
O[k] = value;
k++;
}

// Step 13.
return O;
}
});
}
Number.isInteger = Number.isInteger || function(value) {
return typeof value === 'number' &&
isFinite(value) &&
Math.floor(value) === value;
};
Math.trunc = Math.trunc || function(x) {
var n = x - x%1;
return n===0 && (x<0 || (x===0 && (1/x !== 1/0))) ? -0 : n;
};
3 changes: 3 additions & 0 deletions project/static/libs/modernizr-custom.js

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

5 changes: 5 additions & 0 deletions project/static/libs/respond-1.4.2.min.js

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

6 changes: 6 additions & 0 deletions project/templates/pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
}
</style>

<!-- scripts -->
<script src="{{ url_for('static', filename='libs/modernizr-custom.js')}}"></script>
<script src="{{ url_for('static', filename='js/backCompat.js')}}"></script>
<!--[if lt IE 9]><script src="{{ url_for('static', filename='libs/respond-1.4.2.min.js')}}"></script><![endif]-->
<!-- /scripts -->

</head>

<body>
Expand Down

0 comments on commit 009b63e

Please sign in to comment.