mirror of https://github.com/status-im/consul.git
ui: Move the text encoding polyfill to a a proper detecting polyfill (#4767)
This commit is contained in:
parent
26c94764b8
commit
8ba1c549a9
|
@ -25,6 +25,17 @@
|
|||
</noscript>
|
||||
{{content-for "body"}}
|
||||
<script src="{{rootURL}}assets/vendor.js"></script>
|
||||
<script>
|
||||
var appendScript = function(src) {
|
||||
var $script = document.createElement('script');
|
||||
$script.src = src;
|
||||
document.body.appendChild($script);
|
||||
}
|
||||
if(!('TextDecoder' in window)) {
|
||||
appendScript('{{rootURL}}assets/encoding-indexes.js');
|
||||
appendScript('{{rootURL}}assets/encoding.js');
|
||||
}
|
||||
</script>
|
||||
<script src="{{rootURL}}assets/consul-ui.js"></script>
|
||||
|
||||
{{content-for "body-footer"}}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue