Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: was detecting existence of the script -- not if it had loaded #380

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/asset-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ function main(container, _runner) {
const cssAsset = retrieveEvolvCssAsset(environment);
const jsAsset = retrieveEvolvJsAsset(environment);

const markDOMJSState = function (state) {
document.documentElement.dataset.evolvJs = state;
}
markDOMJSState(jsAsset ? 'loaded' : 'not-requested');

const runner = _runner || new Runner(container);

/**
Expand Down
6 changes: 6 additions & 0 deletions src/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@ export function bootstrap(initialConfig) {
resolve();
});

scriptPromise.then(function() {
document.documentElement.dataset.evolvJs = 'ready';
}).catch(function() {
document.documentElement.dataset.evolvJs = 'errored';
});

Comment on lines +209 to +214
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is better 💯

if (css) {
injectStylesheetWithAutoReplace(endpoint, env, version, uid, previewCid);
}
Expand Down
6 changes: 0 additions & 6 deletions src/tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,6 @@ describe('asset manager handles correctly', () => {
new EvolvAssetManager(client, undefined, mockTiming());
assert.equal(client.confirmations, 1);
assert.equal(client.contaminations, 0);

// verify we mark the status of the assets js load
assert.strictEqual(document.documentElement.dataset.evolvJs, 'not-requested');
});

it('for just javascript - will still confirm - but there is nothing to confirm into', () => {
Expand All @@ -206,9 +203,6 @@ describe('asset manager handles correctly', () => {
assert.equal(true, _mockRunner.updateFunctionsToRun.calledOnce);
assert.deepStrictEqual([], _mockRunner.updateFunctionsToRun.getCall(0).args[0]);
assert.equal(client.contaminations, 0);

// verify we mark the status of the assets js load
assert.strictEqual(document.documentElement.dataset.evolvJs, 'loaded');
});
});

Expand Down
Loading