Skip to content

Commit

Permalink
More fixes for IE11
Browse files Browse the repository at this point in the history
  • Loading branch information
slevithan committed Oct 28, 2020
1 parent ae40d3c commit ca3819b
Show file tree
Hide file tree
Showing 4 changed files with 1,159 additions and 412 deletions.
17 changes: 10 additions & 7 deletions src/xregexp.js
Expand Up @@ -67,16 +67,19 @@ function hasNativeFlag(flag) {
// Can't use regex literals for testing even in a `try` because regex literals with
// unsupported flags cause a compilation error in IE
new RegExp('', flag);

// Work around a broken/incomplete IE11 polyfill for sticky introduced in core-js 3.6.0
if (flag === 'y') {
// Using function to avoid babel transform to regex literal
const gy = (() => 'gy')();
const incompleteY = '.a'.replace(new RegExp('a', gy), '.') === '..';
if (incompleteY) {
isSupported = false;
}
}
} catch (exception) {
isSupported = false;
}
// Work around a broken/incomplete IE11 polyfill for sticky introduced in core-js 3.6.0
if (flag === 'y') {
const incompleteY = '.a'.replace(new RegExp('a', 'gy'), '.') === '..';
if (incompleteY) {
isSupported = false;
}
}
return isSupported;
}
// Check for ES6 `u` flag support
Expand Down
7 changes: 7 additions & 0 deletions tests/helpers/h.js
Expand Up @@ -22,3 +22,10 @@ global.hasStrictMode = (function() {

return !this;
}());

// Naive polyfill of String.prototype.repeat
if (!String.prototype.repeat) {
String.prototype.repeat = function(count) {
return count ? Array(count + 1).join(this) : '';
};
}
2 changes: 1 addition & 1 deletion tests/perf/index.html
Expand Up @@ -24,7 +24,7 @@
var match = /[?&]version=([^&]+)/.exec(location.search);
var version = match ? match[1] : null;
var knownVersion = {
'4.3.0': true,
'4.3.1': true,
'4.2.4': true,
'4.2.3': true,
'4.2.0': true,
Expand Down

0 comments on commit ca3819b

Please sign in to comment.