Skip to content

Commit 23d5338

Browse files
lbogdanCompuIves
authored andcommitted
Preserve resource order (codesandbox#175)
* Fixed typos. * Don't sort resources, keep their order. * Make resource scripts async "the right way".
1 parent e9b0446 commit 23d5338

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/app/pages/Sandbox/Editor/Workspace/Dependencies/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ export default class Dependencies extends React.PureComponent<Props, State> {
141141
<div>
142142
<WorkspaceSubtitle>External Resources</WorkspaceSubtitle>
143143
{(externalResources || [])
144-
.sort()
145144
.map(resource => (
146145
<ExternalResource
147146
key={resource}

src/sandbox/external-resources.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
function getExternalResourcesConcatination(resources: Array<string>) {
2-
return resources.sort().join('');
1+
function getExternalResourcesConcatenation(resources: Array<string>) {
2+
return resources.join('');
33
}
44

55
function clearExternalResources() {
@@ -27,7 +27,7 @@ function addCSS(resource: string) {
2727
function addJS(resource: string) {
2828
const script = document.createElement('script');
2929
script.setAttribute('src', resource);
30-
script.setAttribute('async', false);
30+
script.async = false;
3131
script.setAttribute('id', 'external-js');
3232
document.head.appendChild(script);
3333
}
@@ -44,8 +44,8 @@ function addResource(resource: string) {
4444

4545
let cachedExternalResources = '';
4646

47-
export default function handelExternalResources(externalResources) {
48-
const extResString = getExternalResourcesConcatination(externalResources);
47+
export default function handleExternalResources(externalResources) {
48+
const extResString = getExternalResourcesConcatenation(externalResources);
4949
if (extResString !== cachedExternalResources) {
5050
clearExternalResources();
5151
externalResources.forEach(addResource);

0 commit comments

Comments
 (0)