diff --git a/packages/ember-metal/lib/mixin.js b/packages/ember-metal/lib/mixin.js index a210d0170bb..fbb55db96a1 100644 --- a/packages/ember-metal/lib/mixin.js +++ b/packages/ember-metal/lib/mixin.js @@ -2,7 +2,7 @@ @module @ember/object */ import { EMBER_METAL_ES5_GETTERS } from 'ember/features'; -import { assign, guidFor, ROOT, wrap, makeArray } from 'ember-utils'; +import { assign, guidFor, ROOT, wrap, makeArray, NAME_KEY } from 'ember-utils'; import { assert } from 'ember-debug'; import { DEBUG } from 'ember-env-flags'; import { ENV } from 'ember-environment'; @@ -449,6 +449,7 @@ export default class Mixin { this._without = undefined; if (DEBUG) { + this[NAME_KEY] = undefined; /* In debug builds, we seal mixins to help avoid performance pitfalls. @@ -609,6 +610,7 @@ if (ENV._ENABLE_BINDING_SUPPORT) { Mixin.prototype.toString = classToString; if (DEBUG) { + Mixin.prototype[NAME_KEY] = undefined; Object.seal(Mixin.prototype); } diff --git a/packages/ember-metal/tests/mixin/introspection_test.js b/packages/ember-metal/tests/mixin/introspection_test.js index 446470722a6..1740afc9cf2 100644 --- a/packages/ember-metal/tests/mixin/introspection_test.js +++ b/packages/ember-metal/tests/mixin/introspection_test.js @@ -2,7 +2,7 @@ // as well as methods vs props. We are just keeping these for testing; the // current impl doesn't care about the differences as much... -import { guidFor } from 'ember-utils'; +import { guidFor, NAME_KEY } from 'ember-utils'; import { mixin, Mixin } from '../..'; import { moduleFor, AbstractTestCase } from 'internal-test-helpers'; @@ -58,5 +58,18 @@ moduleFor( 'should return included mixins' ); } + + ['@test setting a NAME_KEY on a mixin does not error'](assert) { + assert.expect(0); + + let instance = Mixin.create(); + instance[NAME_KEY] = 'My special name!'; + } + + ['@test setting a NAME_KEY on a mixin instance does not error'](assert) { + assert.expect(0); + + Mixin.create({ [NAME_KEY]: 'My special name' }); + } } );