Skip to content

Commit

Permalink
Fix bug with removal of line with __suffix component name (#5081)
Browse files Browse the repository at this point in the history
  • Loading branch information
diarmidmackenzie authored Jul 21, 2022
1 parent fb9beae commit 32286e3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/line.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ module.exports.Component = registerComponent('line', {
},

remove: function () {
this.el.removeObject3D('line', this.line);
this.el.removeObject3D(this.attrName, this.line);
}
});

Expand Down
23 changes: 21 additions & 2 deletions tests/components/line.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,23 @@ var entityFactory = require('../helpers').entityFactory;
suite('line', function () {
var el;
var component;
var componentSuffix;

setup(function (done) {
var count = 0;
el = this.el = entityFactory();
el.setAttribute('line', '');
el.setAttribute('line__suffix', '');
if (el.hasLoaded) { done(); }
el.addEventListener('componentinitialized', function (evt) {
if (evt.detail.name !== 'line') { return; }
if (evt.detail.name !== 'line' &&
evt.detail.name !== 'line__suffix') { return; }
component = el.components.line;
done();
componentSuffix = el.components.line__suffix;
count++;
if (count >= 2) {
done();
}
});
});

Expand Down Expand Up @@ -87,5 +95,16 @@ suite('line', function () {

assert.equal(material.color.getHexString(), 'ff99aa');
});

test('Line with __suffix component name', function () {
el.setAttribute('line__suffix', {start: '1 2 3', end: '4 5 6'});
var positionArray = componentSuffix.geometry.attributes.position.array;
assert.equal(positionArray[0], 1);
assert.equal(positionArray[1], 2);
assert.equal(positionArray[2], 3);
assert.equal(positionArray[3], 4);
assert.equal(positionArray[4], 5);
assert.equal(positionArray[5], 6);
});
});
});

0 comments on commit 32286e3

Please sign in to comment.