Skip to content

Commit

Permalink
wait for DOMContentLoaded before initializing components on entity
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentfretin committed Oct 1, 2022
1 parent 29115f9 commit 4de3e6f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/core/a-entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,14 @@ var proto = Object.create(ANode.prototype, {

if (this.hasLoaded || !this.parentEl) { return; }

ANode.prototype.load.call(this, function entityLoadCallback () {
// Check if entity was detached while it was waiting to load.
if (!self.parentEl) { return; }
utils.waitForDOMContentLoaded().then(function () {
ANode.prototype.load.call(self, function entityLoadCallback () {
// Check if entity was detached while it was waiting to load.
if (!self.parentEl) { return; }

self.updateComponents();
if (self.isScene || self.parentEl.isPlaying) { self.play(); }
self.updateComponents();
if (self.isScene || self.parentEl.isPlaying) { self.play(); }
});
});
},
writable: window.debug
Expand Down

0 comments on commit 4de3e6f

Please sign in to comment.