Skip to content

Commit

Permalink
refer retrieving document body until it's loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
analogrelay committed Sep 23, 2022
1 parent 620b392 commit 9107194
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -970,18 +970,17 @@ export class ValidationService {
*/
bootstrap(options?: { watch?: boolean, root?: HTMLElement }) {
options = options || {};
options.root = options.root || window.document.body;

this.addMvcProviders();

// If the document is done loading, scan it now.
if(window.document.readyState !== 'loading') {
this.scan(options.root);
this.scan(options.root || window.document.body);
}
else {
// Otherwise wait until the document is done loading.
window.document.addEventListener('DOMContentLoaded', event => {
this.scan(options.root);
this.scan(options.root || window.document.body);
});
}

Expand Down

0 comments on commit 9107194

Please sign in to comment.