Skip to content

Commit

Permalink
Patch 'Headers' to accept 'undefined'
Browse files Browse the repository at this point in the history
Fixes `TypeError: Failed to construct 'Headers': No matching constructor signature.`
  • Loading branch information
dmitrylyzo committed May 19, 2024
1 parent ed321c4 commit 47f3a4f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import './legacy/domParserTextHtml';
import './legacy/focusPreventScroll';
import './legacy/htmlMediaElement';
import './legacy/keyboardEvent';
import './legacy/patchHeaders';
import './legacy/vendorStyles';
import { currentSettings } from './scripts/settings/userSettings';
import taskButton from './scripts/taskbutton';
Expand Down
26 changes: 26 additions & 0 deletions src/legacy/patchHeaders.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Patch 'Headers' to accept 'undefined'.
* Fixes `TypeError: Failed to construct 'Headers': No matching constructor signature.`
* Affected platforms:
* - Tizen 3
* - Tizen 4
* - webOS 4
*/

(function (window) {
'use strict';

if (window.Headers) {
try {
new window.Headers(undefined);
} catch (_) {
console.debug('patch \'Headers\' to accept \'undefined\'');

var _Headers = window.Headers;

Check failure on line 19 in src/legacy/patchHeaders.js

View workflow job for this annotation

GitHub Actions / Run eslint

Unexpected var, use let or const instead

window.Headers = function (init) {
return init ? new _Headers(init) : new _Headers();
}

Check failure on line 23 in src/legacy/patchHeaders.js

View workflow job for this annotation

GitHub Actions / Run eslint

Missing semicolon
}
}
}(window));

0 comments on commit 47f3a4f

Please sign in to comment.