Skip to content

Commit

Permalink
Fix bug preventing runtime registered components from being sorted in…
Browse files Browse the repository at this point in the history
…to componentOrder
  • Loading branch information
mrxz committed Mar 11, 2024
1 parent 8e95cd1 commit 4478a5e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/scene/a-scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class AScene extends AEntity {
this.componentOrder = solveOrder(components, this.componentOrder);
this.addEventListener('componentregistered', function () {
// Recompute order
this.componentOrder = solveOrder(components, this.componentOrder);
self.componentOrder = solveOrder(components, self.componentOrder);
});

// WebXR Immersive navigation handler.
Expand Down
11 changes: 11 additions & 0 deletions tests/core/scene/a-scene.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,17 @@ suite('a-scene (without renderer) - WebXR', function () {
assert.ok(sceneEl.hasAttribute('screenshot'));
assert.ok(sceneEl.hasAttribute('xr-mode-ui'));
});

test('recomputes component order upon component registration', function () {
var sceneEl = this.el;
var componentCount = sceneEl.componentOrder.length;

assert.ok(componentCount > 0);
assert.notIncludeMembers(sceneEl.componentOrder, ['test']);
registerComponent('test', {});
assert.equal(sceneEl.componentOrder.length, componentCount + 1);
assert.includeMembers(sceneEl.componentOrder, ['test']);
});
});

suite('vrdisplaydisconnect', function () {
Expand Down

0 comments on commit 4478a5e

Please sign in to comment.