Skip to content

Commit d308698

Browse files
author
Mat Brown
committed
Remove remaining use of data URIs
Only one remaining place used data URIs, and it wasn’t particularly necessary—link tags to include CSS libraries in the header. Instead just use a `<style>` tag and inline the CSS.
1 parent 1d93c49 commit d308698

4 files changed

Lines changed: 4 additions & 19 deletions

File tree

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@
100100
"PrettyCSS": "^0.3.13",
101101
"ajv": "^5.2.2",
102102
"array-to-sentence": "^1.1.0",
103-
"base64-js": "^1.0.2",
104103
"bowser": "^1.4.5",
105104
"brace": "^0.10.0",
106105
"bugsnag-js": "^3.0.1",
@@ -147,7 +146,6 @@
147146
"rxjs": "^5.0.2",
148147
"slowparse": "^1.1.4",
149148
"stylelint": "^8.0.0",
150-
"text-encoding": "^0.6.0",
151149
"uuid": "^3.1.0",
152150
"void-elements": "^3.1.0"
153151
},

src/templates.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/util/generatePreview.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@ import flatMap from 'lodash/flatMap';
44
import isEmpty from 'lodash/isEmpty';
55
import pick from 'lodash/pick';
66
import uniq from 'lodash/uniq';
7-
import base64 from 'base64-js';
8-
import {TextEncoder} from 'text-encoding';
97
import loopBreaker from 'loop-breaker';
108
import libraries from '../config/libraries';
119
import previewFrameLibraries from '../config/previewFrameLibraries';
1210

13-
const textEncoder = new TextEncoder('utf-8');
1411
const parser = new DOMParser();
1512

1613
const sourceDelimiter = '/*__POPCODESTART__*/';
@@ -204,12 +201,9 @@ class PreviewGenerator {
204201
}
205202

206203
_attachCssLibrary(css) {
207-
const linkTag = this.previewDocument.createElement('link');
208-
linkTag.rel = 'stylesheet';
209-
210-
const base64encoded = base64.fromByteArray(textEncoder.encode(css));
211-
linkTag.href = `data:text/css;charset=utf-8;base64,${base64encoded}`;
212-
this._previewHead.appendChild(linkTag);
204+
const styleTag = this.previewDocument.createElement('style');
205+
styleTag.textContent = String(css);
206+
this._previewHead.appendChild(styleTag);
213207
}
214208

215209
_attachJavascriptLibrary(javascript) {

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8019,7 +8019,7 @@ tempfile@^1.1.1:
80198019
os-tmpdir "^1.0.0"
80208020
uuid "^2.0.1"
80218021

8022-
text-encoding@0.6.4, text-encoding@^0.6.0:
8022+
text-encoding@0.6.4:
80238023
version "0.6.4"
80248024
resolved "https://registry.yarnpkg.com/text-encoding/-/text-encoding-0.6.4.tgz#e399a982257a276dae428bb92845cb71bdc26d19"
80258025

0 commit comments

Comments
 (0)