Use text-encoding-utf-8 as a TextEncoder polyfill

Somebody else seems to have done a good job of polyfilling TextEncoder, so
let's use that.
This commit is contained in:
Richard van der Hoff 2017-01-18 11:39:44 +00:00
parent 09ce74cc76
commit 31df78f946
7 changed files with 89 additions and 336 deletions

View file

@ -17,13 +17,14 @@ limitations under the License.
"use strict";
// polyfill textencoder if necessary
import * as TextEncodingUtf8 from 'text-encoding-utf-8';
let TextEncoder = window.TextEncoder;
if (!TextEncoder) {
TextEncoder = require('./TextEncoderPolyfill');
TextEncoder = TextEncodingUtf8.TextEncoder;
}
let TextDecoder = window.TextDecoder;
if (TextDecoder) {
TextDecoder = require('./TextDecoderPolyfill');
if (!TextDecoder) {
TextDecoder = TextEncodingUtf8.TextDecoder;
}
const subtleCrypto = window.crypto.subtle || window.crypto.webkitSubtle;