Skip to content

Commit

Permalink
(tsoding#67) Fix URLSearchParams
Browse files Browse the repository at this point in the history
  • Loading branch information
somerandomdev49 committed Jun 20, 2021
1 parent f653e6a commit 8c41d93
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
16 changes: 15 additions & 1 deletion js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,21 @@ function FilterSelector() {
return root;
}
window.onload = function () {
feature_params = new URLSearchParams(document.location.search).has("feature-params");
if (URLSearchParams) {
feature_params = new URLSearchParams(document.location.search).has("feature-params");
}
else {
var query = document.location.toString().split('?')[1];
feature_params = false;
if (query) {
for (var _i = 0, _a = query.split('&'); _i < _a.length; _i++) {
var el = _a[_i];
if (el === "feature-params") {
feature_params = true;
}
}
}
}
var filterSelectorEntry = document.getElementById('filter-selector-entry');
if (filterSelectorEntry === null) {
throw new Error('Could not find "filter-selector-entry"');
Expand Down
16 changes: 15 additions & 1 deletion ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,21 @@ function FilterSelector() {
}

window.onload = () => {
feature_params = new URLSearchParams(document.location.search).has("feature-params");
if (URLSearchParams) {
feature_params = new URLSearchParams(document.location.search).has("feature-params");
} else {
// IE support
const query = document.location.toString().split('?')[1];
feature_params = false;
if (query) {
// IE doesnt have Array.includes()
for (const el of query.split('&')) {
if (el === "feature-params") {
feature_params = true;
}
}
}
}

const filterSelectorEntry = document.getElementById('filter-selector-entry');
if (filterSelectorEntry === null) {
Expand Down

0 comments on commit 8c41d93

Please sign in to comment.