Skip to content

Commit

Permalink
Accept el.setAttribute('mixin', '') (aframevr#2291)
Browse files Browse the repository at this point in the history
  • Loading branch information
takahirox authored and ngokevin committed Jan 17, 2017
1 parent 46f8e36 commit fb5e95c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/a-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ module.exports = registerElement('a-node', {

updateMixins: {
value: function (newMixins, oldMixins) {
var newMixinsIds = newMixins.split(' ');
var newMixinsIds = newMixins ? newMixins.split(' ') : [];
var oldMixinsIds = oldMixins ? oldMixins.split(' ') : [];
// To determine what listeners will be removed
var diff = oldMixinsIds.filter(function (i) { return newMixinsIds.indexOf(i) < 0; });
Expand Down
13 changes: 13 additions & 0 deletions tests/core/a-entity.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,19 @@ suite('a-entity', function () {
assert.equal(el.getAttribute('sound__2').src, soundUrl);
assert.equal(el.getAttribute('sound__2').autoplay, true);
});

test('clear mixin', function () {
var el = this.el;
mixinFactory('material', {material: 'shader: flat'});
mixinFactory('position', {position: '1 2 3'});
el.setAttribute('mixin', 'material position');
el.setAttribute('material', 'color: red');
assert.shallowDeepEqual(el.getAttribute('material'), {shader: 'flat', color: 'red'});
assert.shallowDeepEqual(el.getAttribute('position'), {x: 1, y: 2, z: 3});
el.setAttribute('mixin', '');
assert.shallowDeepEqual(el.getAttribute('material'), {color: 'red'});
assert.shallowDeepEqual(el.getAttribute('position'), {x: 0, y: 0, z: 0});
});
});
});

Expand Down

0 comments on commit fb5e95c

Please sign in to comment.