Skip to content

Commit

Permalink
Add check for block-level function support in the preflight compatibi…
Browse files Browse the repository at this point in the history
…liy test

This way we correctly alert IE10 and Safari 8-9 users that their browsers are not supported.
  • Loading branch information
bago committed Sep 16, 2022
1 parent fee0007 commit e30fa33
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/js/template-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ var templateCompiler = function(performanceAwareCaller, templateUrlConverter, te

var checkFeature = function(feature, func) {
if (!func()) {
console.warn("Missing required browser feature", feature);
console.warn("Missing required browser feature: ", feature);
throw "Missing required browser feature: " + feature;
}
};
Expand All @@ -365,6 +365,16 @@ var isCompatible = function(detailedException) {
checkFeature('matchMedia', function() {
return typeof global.matchMedia != 'undefined';
});
// Since 0.18 some of our dependencies use block level functions in strict-mode:
// They throw a parsing error in IE10 and Safari 8-9 that we previously supported.
checkFeature('Block-level functions', function() {
try {
new Function('\'use strict\'; { function g() { } }');
return true;
} catch (e) {
return false;
}
});
checkFeature('XMLHttpRequest 2', function() {
return 'XMLHttpRequest' in global && 'withCredentials' in new global.XMLHttpRequest();
});
Expand Down

0 comments on commit e30fa33

Please sign in to comment.