Skip to content

Commit a173509

Browse files
processprocessngokevin
authored andcommitted
allow unsetting mixin with setAttribute('mixin', '') and removeAttribute
1 parent 9bab418 commit a173509

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

‎src/core/a-entity.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,11 @@ var proto = Object.create(ANode.prototype, {
567567
return;
568568
}
569569

570+
if (attr === 'mixin') {
571+
this.updateMixins();
572+
return;
573+
}
574+
570575
HTMLElement.prototype.removeAttribute.call(this, attr);
571576
}
572577
},

‎src/core/a-node.js‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,16 @@ module.exports = registerElement('a-node', {
131131
value: function (newMixins, oldMixins) {
132132
var newMixinsIds = newMixins ? newMixins.trim().split(/\s+/) : [];
133133
var oldMixinsIds = oldMixins ? oldMixins.trim().split(/\s+/) : [];
134+
135+
if (!newMixins) {
136+
var mixinEls = this.mixinEls;
137+
for (var i = 0; i < mixinEls.length; i++) {
138+
this.unregisterMixin(mixinEls[i].id);
139+
}
140+
HTMLElement.prototype.removeAttribute.call(this, 'mixin');
141+
return;
142+
}
143+
134144
// To determine what listeners will be removed
135145
var diff = oldMixinsIds.filter(function (i) { return newMixinsIds.indexOf(i) < 0; });
136146
this.mixinEls = [];

0 commit comments

Comments
 (0)