Skip to content

Commit

Permalink
Remove attribute from DOM when removing component (through mixin remo…
Browse files Browse the repository at this point in the history
…val/update) (#5492)

Co-authored-by: Noeri Huisman <mrxz@users.noreply.github.com>
  • Loading branch information
mrxz and mrxz committed Mar 7, 2024
1 parent 53bc87f commit 555bd47
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/core/a-entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,10 @@ class AEntity extends ANode {
if (destroy) {
component.destroy();
delete this.components[name];
// Remove attribute from DOM, if still present
if (this.hasAttribute(name)) {
window.HTMLElement.prototype.removeAttribute.call(this, name);
}
}

this.emit('componentremoved', component.evtDetail, false);
Expand Down
2 changes: 1 addition & 1 deletion tests/core/a-mixin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ suite('a-mixin', function () {
testEl.setAttribute('delete-mixin', '');
testEl.addEventListener('loaded', function () {
assert.equal(testEl.getAttribute('mixin'), null);
assert.equal(testEl.getAttribute('material'), '');
assert.equal(testEl.getAttribute('material'), null);
done();
});
el.sceneEl.appendChild(testEl);
Expand Down

0 comments on commit 555bd47

Please sign in to comment.