diff --git a/src/core/a-register-element.js b/src/core/a-register-element.js index 4eaf5070fd2..4db6b1c709a 100644 --- a/src/core/a-register-element.js +++ b/src/core/a-register-element.js @@ -58,6 +58,14 @@ module.exports.registerElement = function (tagName, obj) { newObj = {prototype: Object.create(proto, newObj)}; } + // Give all functions their proper name. + for (var propName of Object.getOwnPropertyNames(newObj.prototype)) { + var propVal = newObj.prototype[propName]; + if (typeof propVal === 'function') { + propVal.displayName = propName; + } + } + return document.registerElement(tagName, newObj); }; diff --git a/tests/core/a-register-element.test.js b/tests/core/a-register-element.test.js index 605610b2d14..f105c30ec9c 100644 --- a/tests/core/a-register-element.test.js +++ b/tests/core/a-register-element.test.js @@ -65,6 +65,20 @@ suite('a-register-element', function () { }); document.body.appendChild(document.createElement('a-test-entity-2')); }); + + test('names functions correctly', function (done) { + registerElement('a-test-entity-3', { + prototype: Object.create(AEntity.prototype, { + attachedCallback: { + value: function () { + assert.equal(this.attachedCallback.displayName, 'attachedCallback'); + done(); + } + } + }) + }); + document.body.appendChild(document.createElement('a-test-entity-3')); + }); }); suite('wrapMethods', function () {