Skip to content

Commit 447a3fd

Browse files
committed
Remove TextEncoder/TextDecoder polyfill
This was only relevant for legacy Edge which is not supported anymore
1 parent 0611932 commit 447a3fd

File tree

3 files changed

+2
-24
lines changed

3 files changed

+2
-24
lines changed

package-lock.json

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
"base64-loader": "1.0.0",
2929
"css-tree": "1.1.3",
3030
"dompurify": "^2.5.6",
31-
"fastestsmallesttextencoderdecoder": "^1.0.22",
3231
"transformation-matrix": "1.15.0"
3332
},
3433
"devDependencies": {

src/sanitize-svg.js

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,29 +54,14 @@ if (DOMPurify.isSupported) {
5454
);
5555
}
5656

57-
// Use JS implemented TextDecoder and TextEncoder if it is not provided by the
58-
// browser.
59-
let _TextDecoder;
60-
let _TextEncoder;
61-
if (typeof TextDecoder === 'undefined' || typeof TextEncoder === 'undefined') {
62-
// Wait to require the text encoding polyfill until we know it's needed.
63-
// eslint-disable-next-line global-require
64-
const encoding = require('fastestsmallesttextencoderdecoder');
65-
_TextDecoder = encoding.TextDecoder;
66-
_TextEncoder = encoding.TextEncoder;
67-
} else {
68-
_TextDecoder = TextDecoder;
69-
_TextEncoder = TextEncoder;
70-
}
71-
7257
/**
7358
* Load an SVG Uint8Array of bytes and "sanitize" it
7459
* @param {!Uint8Array} rawData unsanitized SVG daata
7560
* @return {Uint8Array} sanitized SVG data
7661
*/
7762
sanitizeSvg.sanitizeByteStream = function (rawData) {
78-
const decoder = new _TextDecoder();
79-
const encoder = new _TextEncoder();
63+
const decoder = new TextDecoder();
64+
const encoder = new TextEncoder();
8065
const sanitizedText = sanitizeSvg.sanitizeSvgText(decoder.decode(rawData));
8166
return encoder.encode(sanitizedText);
8267
};

0 commit comments

Comments
 (0)