diff --git a/src/core/schema.js b/src/core/schema.js index 905a60b1ec4..103e211993a 100644 --- a/src/core/schema.js +++ b/src/core/schema.js @@ -187,7 +187,9 @@ module.exports.stringifyProperties = function (propData, schema) { value = stringifyProperty(propValue, propDefinition); if (!propDefinition) { warn('Unknown component property: ' + propName); } } - stringifiedData[propName] = value; + if (value !== undefined) { + stringifiedData[propName] = value; + } } return stringifiedData; }; diff --git a/tests/core/component.test.js b/tests/core/component.test.js index 8331a05e078..045a59c894d 100644 --- a/tests/core/component.test.js +++ b/tests/core/component.test.js @@ -1149,6 +1149,19 @@ suite('Component', function () { el.components.dummy.flushToDOM(); assert.equal(HTMLElement.prototype.getAttribute.call(el, 'dummy'), 'isDurrr: false'); }); + + test('omits cleared properties', function () { + var el = document.createElement('a-entity'); + registerComponent('dummy', { + schema: {name: {type: 'string'}} + }); + el.setAttribute('dummy', 'name', 'John'); + el.components.dummy.flushToDOM(); + assert.equal(HTMLElement.prototype.getAttribute.call(el, 'dummy'), 'name: John'); + el.setAttribute('dummy', 'name', ''); + el.components.dummy.flushToDOM(); + assert.equal(HTMLElement.prototype.getAttribute.call(el, 'dummy'), ''); + }); }); suite('play', function () {