From 8ba1c549a90df8aded368d387ced303f0f4c9452 Mon Sep 17 00:00:00 2001 From: John Cowen Date: Mon, 8 Oct 2018 17:47:44 +0100 Subject: [PATCH] ui: Move the text encoding polyfill to a a proper detecting polyfill (#4767) --- ui-v2/app/index.html | 11 +++++++++++ ui-v2/app/utils/atob.js | 5 +---- ui-v2/app/utils/btoa.js | 3 +-- ui-v2/ember-cli-build.js | 2 ++ 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/ui-v2/app/index.html b/ui-v2/app/index.html index 1cc46837507d..f88cc23e4c28 100644 --- a/ui-v2/app/index.html +++ b/ui-v2/app/index.html @@ -25,6 +25,17 @@

JavaScript Required

{{content-for "body"}} + {{content-for "body-footer"}} diff --git a/ui-v2/app/utils/atob.js b/ui-v2/app/utils/atob.js index f2df4317ee47..bf3960bc41a9 100644 --- a/ui-v2/app/utils/atob.js +++ b/ui-v2/app/utils/atob.js @@ -1,9 +1,6 @@ -import TextEncoding from 'npm:text-encoding'; import base64js from 'npm:base64-js'; export default function(str, encoding = 'utf-8') { // decode const bytes = base64js.toByteArray(str); - return new ('TextDecoder' in window ? TextDecoder : TextEncoding.TextDecoder)(encoding).decode( - bytes - ); + return new TextDecoder(encoding).decode(bytes); } diff --git a/ui-v2/app/utils/btoa.js b/ui-v2/app/utils/btoa.js index ae1c058adb04..47aedc876687 100644 --- a/ui-v2/app/utils/btoa.js +++ b/ui-v2/app/utils/btoa.js @@ -1,7 +1,6 @@ -import TextEncoding from 'npm:text-encoding'; import base64js from 'npm:base64-js'; export default function(str, encoding = 'utf-8') { // encode - const bytes = new ('TextEncoder' in window ? TextEncoder : TextEncoding.TextEncoder)(encoding).encode(str); + const bytes = new TextEncoder(encoding).encode(str); return base64js.fromByteArray(bytes); } diff --git a/ui-v2/ember-cli-build.js b/ui-v2/ember-cli-build.js index a82f0478c6d1..46e24575a361 100644 --- a/ui-v2/ember-cli-build.js +++ b/ui-v2/ember-cli-build.js @@ -65,6 +65,8 @@ module.exports = function(defaults) { // modules that you would like to import into your application // please specify an object with the list of modules as keys // along with the exports of each module as its value. + app.import('node_modules/text-encoding/lib/encoding-indexes.js', {outputFile: 'assets/encoding-indexes.js'}) + app.import('node_modules/text-encoding/lib/encoding.js', {outputFile: 'assets/encoding.js'}) let tree = app.toTree(); return tree; };