Skip to content

Commit

Permalink
Revert "[BUGFIX Model] assert when 'content' is used as a property on…
Browse files Browse the repository at this point in the history
… a record (emberjs#7545)"

This reverts commit 1d1496d.
  • Loading branch information
mansona committed Aug 28, 2021
1 parent 7d87813 commit cb0768c
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 20 deletions.
9 changes: 1 addition & 8 deletions packages/-ember-data/tests/unit/model-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -757,15 +757,8 @@ module('unit/model - Model', function (hooks) {
@attr('string')
name;
}
class NativePostWithContent extends Model {
@attr('string')
content;
@attr('string')
name;
}
const PROP_MAP = {
_internalModel: NativePostWithInternalModel,
content: NativePostWithContent,
currentState: NativePostWithCurrentState,
};

Expand Down Expand Up @@ -805,7 +798,7 @@ module('unit/model - Model', function (hooks) {
});
}

['_internalModel', 'content', 'currentState'].forEach(testReservedProperty);
['_internalModel', 'currentState'].forEach(testReservedProperty);

testInDebug('A subclass of Model throws an error when calling create() directly', async function (assert) {
class NativePerson extends Model {}
Expand Down
4 changes: 2 additions & 2 deletions packages/model/addon/-private/attr.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function attr(type, options) {
return computed({
get(key) {
if (DEBUG) {
if (['_internalModel', 'content', 'currentState'].indexOf(key) !== -1) {
if (['_internalModel', 'currentState'].indexOf(key) !== -1) {
throw new Error(
`'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your attr on ${this.constructor.toString()}`
);
Expand All @@ -145,7 +145,7 @@ function attr(type, options) {
},
set(key, value) {
if (DEBUG) {
if (['_internalModel', 'content', 'currentState'].indexOf(key) !== -1) {
if (['_internalModel', 'currentState'].indexOf(key) !== -1) {
throw new Error(
`'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your attr on ${this.constructor.toString()}`
);
Expand Down
4 changes: 2 additions & 2 deletions packages/model/addon/-private/belongs-to.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function belongsTo(modelName, options) {
return computed({
get(key) {
if (DEBUG) {
if (['_internalModel', 'content', 'recordData', 'currentState'].indexOf(key) !== -1) {
if (['_internalModel', 'recordData', 'currentState'].indexOf(key) !== -1) {
throw new Error(
`'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your belongsTo on ${this.constructor.toString()}`
);
Expand Down Expand Up @@ -170,7 +170,7 @@ function belongsTo(modelName, options) {
},
set(key, value) {
if (DEBUG) {
if (['_internalModel', 'content', 'recordData', 'currentState'].indexOf(key) !== -1) {
if (['_internalModel', 'recordData', 'currentState'].indexOf(key) !== -1) {
throw new Error(
`'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your belongsTo on ${this.constructor.toString()}`
);
Expand Down
4 changes: 2 additions & 2 deletions packages/model/addon/-private/has-many.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ function hasMany(type, options) {
return computed({
get(key) {
if (DEBUG) {
if (['_internalModel', 'content', 'recordData', 'currentState'].indexOf(key) !== -1) {
if (['_internalModel', 'recordData', 'currentState'].indexOf(key) !== -1) {
throw new Error(
`'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your hasMany on ${this.constructor.toString()}`
);
Expand All @@ -190,7 +190,7 @@ function hasMany(type, options) {
},
set(key, records) {
if (DEBUG) {
if (['_internalModel', 'content', 'recordData', 'currentState'].indexOf(key) !== -1) {
if (['_internalModel', 'recordData', 'currentState'].indexOf(key) !== -1) {
throw new Error(
`'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your hasMany on ${this.constructor.toString()}`
);
Expand Down
6 changes: 0 additions & 6 deletions packages/model/addon/-private/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -2279,12 +2279,6 @@ if (DEBUG) {
);
}

if (!isDefaultEmptyDescriptor(this, 'content') || this.content !== undefined) {
throw new Error(
`'content' is a reserved property name on instances of classes extending Model. Please choose a different property name for ${this.constructor.toString()}`
);
}

let ourDescriptor = lookupDescriptor(Model.prototype, 'currentState');
let theirDescriptor = lookupDescriptor(this, 'currentState');
let realState = this.___recordState || this._internalModel.currentState;
Expand Down

0 comments on commit cb0768c

Please sign in to comment.