Skip to content

Commit

Permalink
Drop support for Internet Explorer (#1313)
Browse files Browse the repository at this point in the history
WordPress abandoned the support of IE with WP5.8 in July 2021.
https://wordpress.org/news/2021/05/dropping-support-for-internet-explorer-11/

Though we don't require that version of WP, it's time to abandon
that legacy. See also this very old ticket: #32.

1) Remove workaround for `RegExp:@@split`
See also https://caniuse.com/mdn-javascript_builtins_regexp_--split

2) Add more debug info about browser in the troubleshooting section.
  • Loading branch information
herrvigg committed Apr 7, 2023
1 parent ba8e615 commit 69edb6e
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 46 deletions.
2 changes: 1 addition & 1 deletion dist/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/options.js

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

23 changes: 3 additions & 20 deletions js/core/qblocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,9 @@ const qTranslateConfig = window.qTranslateConfig;
export const qtranxj_get_split_blocks = function (text) {
const regex = '(<!--:lang-->|<!--:-->|\\[:lang]|\\[:]|{:lang}|{:})'.replace(/lang/g, qTranslateConfig.lang_code_format);
const splitRegex = new RegExp(regex, "gi");

// Most browsers support RegExp.prototype[@@split]()... except IE
if ('a~b'.split(/(~)/).length === 3) {
return text.split(splitRegex);
}

// compatibility for unsupported engines
let start = 0, arr = [];
let result;
while ((result = splitRegex.exec(text)) != null) {
arr.push(text.slice(start, result.index));
if (result.length > 1)
arr.push(result[1]);
start = splitRegex.lastIndex;
}
if (start < text.length)
arr.push(text.slice(start));
if (start === text.length)
arr.push(''); // delimiter at the end
return arr;
// Most browsers support RegExp.prototype[@@split]()... except IE (see debug info from troubleshooting)
// https://caniuse.com/mdn-javascript_builtins_regexp_--split
return text.split(splitRegex);
};

export const qtranxj_split = function (text) {
Expand Down
10 changes: 8 additions & 2 deletions js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,12 @@ $(function () {

$('#qtranxs_debug_query').on('click', function () {
const cookies = document.cookie.split(';');
// Check "RegExp: @@split" support, see also: https://caniuse.com/mdn-javascript_builtins_regexp_--split
const isRegexSplitSupported = ('a~b'.split(/(~)/).length === 3);
const browserInfo = {
'cookies': [],
'navigator': navigator.userAgent
'navigator': navigator.userAgent,
'Javascript built-in RegExp: @@split': isRegexSplitSupported ? 'supported' : 'not supported!',
};
for (let i = 0; i < cookies.length; i++) {
const cookieStr = cookies[i].trim();
Expand All @@ -82,10 +85,13 @@ $(function () {
}
}

$('#qtranxs_debug_info').show();
if (!isRegexSplitSupported) {
$('#qtranxs_debug_info_browser').css('color', 'red');
}
$('#qtranxs_debug_info_browser').val(JSON.stringify(browserInfo, null, 2));
$('#qtranxs_debug_info_versions').val('...');
$('#qtranxs_debug_info_configuration').val('...');
$('#qtranxs_debug_info').show();

$.ajax({
url: ajaxurl,
Expand Down
42 changes: 21 additions & 21 deletions package-lock.json

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
Expand Up @@ -26,7 +26,7 @@
"@babel/core": "^7.21.4",
"@babel/preset-env": "^7.21.4",
"babel-loader": "^9.1.2",
"webpack": "^5.76.2",
"webpack": "^5.78.0",
"webpack-cli": "^5.0.1"
},
"dependencies": {}
Expand Down

0 comments on commit 69edb6e

Please sign in to comment.