Skip to content

Commit

Permalink
177 fire customEvent from domready (#179)
Browse files Browse the repository at this point in the history
* Make domready event publically available

* Make event name and variable consistent

* Correct casing
  • Loading branch information
bameyrick authored Feb 15, 2019
1 parent d4ce6d4 commit 59f6828
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/js/domready.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ const onReady = () => {
isReady = true;
callbacks.forEach(fn => fn.call());
document.removeEventListener(eventReady, onReady);

const event = new CustomEvent('onsDOMReady');

document.dispatchEvent(event);
window.onsDOMReady = true;
};

export default function ready(fn, ready = isReady) {
Expand Down
4 changes: 1 addition & 3 deletions src/js/polyfills/await-polyfills.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ export const awaitPolyfills = new Promise(resolve => {
if (window.polyfillsLoaded) {
resolve();
} else {
document.addEventListener(polyfillsReadyEvent, () => {
resolve();
});
document.addEventListener(polyfillsReadyEvent, resolve);
}
});

0 comments on commit 59f6828

Please sign in to comment.