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

bug(polyfill) - fix polyfill loading. #1583

Merged
merged 2 commits into from
Jun 19, 2018
Merged
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
17 changes: 9 additions & 8 deletions src/clientLoader.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
// polyfills
import main from './client';
const readyStates = new Set(['complete', 'loaded', 'interactive']);

function loadMainClient() {
const main = require('./client').default; // eslint-disable-line global-require
main();
}

function run() {
// Run the application when both DOM is ready and page content is loaded
if (
['complete', 'loaded', 'interactive'].includes(document.readyState) &&
document.body
) {
main();
if (readyStates.has(document.readyState) && document.body) {
loadMainClient();
} else {
document.addEventListener('DOMContentLoaded', main, false);
document.addEventListener('DOMContentLoaded', loadMainClient, false);
}
}

Expand Down