diff --git a/addon/-private/system/clone-null.js b/addon/-private/system/clone-null.js index 97210f5353c..9972c430fef 100644 --- a/addon/-private/system/clone-null.js +++ b/addon/-private/system/clone-null.js @@ -1,6 +1,5 @@ -import EmptyObject from "./empty-object"; export default function cloneNull(source) { - let clone = new EmptyObject(); + let clone = Object.create(null); for (let key in source) { clone[key] = source[key]; } diff --git a/addon/-private/system/model/internal-model.js b/addon/-private/system/model/internal-model.js index ea025758679..6d101ac1365 100644 --- a/addon/-private/system/model/internal-model.js +++ b/addon/-private/system/model/internal-model.js @@ -3,7 +3,6 @@ import { assert, runInDebug } from "ember-data/-private/debug"; import RootState from "./states"; import Relationships from "../relationships/state/create"; import Snapshot from "../snapshot"; -import EmptyObject from "../empty-object"; import isEnabled from '../../features'; import OrderedSet from "../ordered-set"; @@ -42,10 +41,10 @@ const assign = Ember.assign || Ember.merge; and setups. It may also be faster to do a two level cache (from: { to }) instead of caching based on a key that adds the two together. */ -const TransitionChainMap = new EmptyObject(); +const TransitionChainMap = Object.create(null); -const _extractPivotNameCache = new EmptyObject(); -const _splitOnDotCache = new EmptyObject(); +const _extractPivotNameCache = Object.create(null); +const _splitOnDotCache = Object.create(null); function splitOnDot(name) { return _splitOnDotCache[name] || ( @@ -180,7 +179,7 @@ export default class InternalModel { get references() { if (this._references === null) { - this._references = new EmptyObject(); + this._references = Object.create(null); } return this._references; } @@ -194,7 +193,7 @@ export default class InternalModel { get _attributes() { if (this.__attributes === null) { - this.__attributes = new EmptyObject(); + this.__attributes = Object.create(null); } return this.__attributes; } @@ -213,7 +212,7 @@ export default class InternalModel { get _inFlightAttributes() { if (this.__inFlightAttributes === null) { - this.__inFlightAttributes = new EmptyObject(); + this.__inFlightAttributes = Object.create(null); } return this.__inFlightAttributes; } @@ -224,7 +223,7 @@ export default class InternalModel { get _data() { if (this.__data === null) { - this.__data = new EmptyObject(); + this.__data = Object.create(null); } return this.__data; } @@ -262,7 +261,7 @@ export default class InternalModel { */ get _implicitRelationships() { if (this.__implicitRelationships === null) { - this.__implicitRelationships = new EmptyObject(); + this.__implicitRelationships = Object.create(null); } return this.__implicitRelationships; } @@ -598,7 +597,7 @@ export default class InternalModel { flushChangedAttributes() { heimdall.increment(flushChangedAttributes); this._inFlightAttributes = this._attributes; - this._attributes = new EmptyObject(); + this._attributes = Object.create(null); } hasChangedAttributes() { @@ -647,7 +646,7 @@ export default class InternalModel { let currentData = this._attributes; let inFlightData = this._inFlightAttributes; let newData = assign(copy(inFlightData), currentData); - let diffData = new EmptyObject(); + let diffData = Object.create(null); let newDataKeys = Object.keys(newData); for (let i = 0, length = newDataKeys.length; i < length; i++) { @@ -719,10 +718,10 @@ export default class InternalModel { rollbackAttributes() { let dirtyKeys = Object.keys(this._attributes); - this._attributes = new EmptyObject(); + this._attributes = Object.create(null); if (get(this, 'isError')) { - this._inFlightAttributes = new EmptyObject(); + this._inFlightAttributes = Object.create(null); this.didCleanError(); } @@ -739,7 +738,7 @@ export default class InternalModel { } if (this.isValid()) { - this._inFlightAttributes = new EmptyObject(); + this._inFlightAttributes = Object.create(null); } this.send('rolledBack'); @@ -1005,7 +1004,7 @@ export default class InternalModel { assign(this._data, data); } - this._inFlightAttributes = new EmptyObject(); + this._inFlightAttributes = Object.create(null); this.send('didCommit'); this.updateRecordArrays(); @@ -1071,7 +1070,7 @@ export default class InternalModel { attrs[keys[i]] = this._inFlightAttributes[keys[i]]; } } - this._inFlightAttributes = new EmptyObject(); + this._inFlightAttributes = Object.create(null); } /* @@ -1124,7 +1123,7 @@ export default class InternalModel { let length = keys.length; let attrs = this._attributes; - original = assign(new EmptyObject(), this._data); + original = assign(Object.create(null), this._data); original = assign(original, this._inFlightAttributes); for (i = 0; i < length; i++) { diff --git a/addon/-private/system/model/model.js b/addon/-private/system/model/model.js index 73335d61734..e2cd3c9b853 100644 --- a/addon/-private/system/model/model.js +++ b/addon/-private/system/model/model.js @@ -4,7 +4,6 @@ import { PromiseObject } from "../promise-proxies"; import Errors from "../model/errors"; import isEnabled from '../../features'; import RootState from '../model/states'; -import EmptyObject from "../empty-object"; import { relationshipsByNameDescriptor, relatedTypesDescriptor, @@ -1272,7 +1271,7 @@ Model.reopenClass({ }, inverseMap: Ember.computed(function() { - return new EmptyObject(); + return Object.create(null); }), /** diff --git a/addon/-private/system/relationships/state/create.js b/addon/-private/system/relationships/state/create.js index 1e7756b0329..f97bcb72776 100644 --- a/addon/-private/system/relationships/state/create.js +++ b/addon/-private/system/relationships/state/create.js @@ -1,7 +1,6 @@ import Ember from 'ember'; import ManyRelationship from "./has-many"; import BelongsToRelationship from "./belongs-to"; -import EmptyObject from "../../empty-object"; import { runInDebug } from 'ember-data/-private/debug'; const { get } = Ember; @@ -37,7 +36,7 @@ function createRelationshipFor(internalModel, relationshipMeta, store) { export default class Relationships { constructor(internalModel) { this.internalModel = internalModel; - this.initializedRelationships = new EmptyObject(); + this.initializedRelationships = Object.create(null); } // TODO @runspired deprecate this as it was never truly a record instance diff --git a/addon/-private/system/snapshot.js b/addon/-private/system/snapshot.js index 0403458b2aa..fde441e26e8 100644 --- a/addon/-private/system/snapshot.js +++ b/addon/-private/system/snapshot.js @@ -3,7 +3,6 @@ */ import Ember from 'ember'; -import EmptyObject from "./empty-object"; const { get @@ -18,11 +17,11 @@ const { */ export default class Snapshot { constructor(internalModel, options = {}) { - this._attributes = new EmptyObject(); - this._belongsToRelationships = new EmptyObject(); - this._belongsToIds = new EmptyObject(); - this._hasManyRelationships = new EmptyObject(); - this._hasManyIds = new EmptyObject(); + this._attributes = Object.create(null); + this._belongsToRelationships = Object.create(null); + this._belongsToIds = Object.create(null); + this._hasManyRelationships = Object.create(null); + this._hasManyIds = Object.create(null); this._internalModel = internalModel; let record = internalModel.getRecord(); @@ -144,7 +143,7 @@ export default class Snapshot { @return {Object} All changed attributes of the current snapshot */ changedAttributes() { - let changedAttributes = new EmptyObject(); + let changedAttributes = Object.create(null); let changedAttributeKeys = Object.keys(this._changedAttributes); for (let i=0, length = changedAttributeKeys.length; i < length; i++) { diff --git a/addon/-private/system/store.js b/addon/-private/system/store.js index f57a2f8f4ec..445e883d2fa 100644 --- a/addon/-private/system/store.js +++ b/addon/-private/system/store.js @@ -44,7 +44,6 @@ import coerceId from "./coerce-id"; import RecordArrayManager from "./record-array-manager"; import ContainerInstanceCache from './store/container-instance-cache'; import InternalModel from "./model/internal-model"; -import EmptyObject from "./empty-object"; import isEnabled from '../features'; export let badIdFormatAssertion = '`id` passed to `findRecord()` has to be non-empty string or number'; @@ -219,7 +218,7 @@ Store = Service.extend({ this._identityMap = new IdentityMap(); this._pendingSave = []; this._instanceCache = new ContainerInstanceCache(getOwner(this), this); - this._modelFactoryCache = new EmptyObject(); + this._modelFactoryCache = Object.create(null); /* Ember Data uses several specialized micro-queues for organizing @@ -349,7 +348,7 @@ Store = Service.extend({ assert(`You need to pass a model name to the store's createRecord method`, isPresent(modelName)); assert(`Passing classes to store methods has been removed. Please pass a dasherized string instead of ${modelName}`, typeof modelName === 'string'); let normalizedModelName = normalizeModelName(modelName); - let properties = copy(inputProperties) || new EmptyObject(); + let properties = copy(inputProperties) || Object.create(null); // If the passed properties do not include a primary key, // give the adapter an opportunity to generate one. Typically, @@ -860,7 +859,7 @@ Store = Service.extend({ let shouldCoalesce = !!adapter.findMany && adapter.coalesceFindRequests; let totalItems = pendingFetchItems.length; let internalModels = new Array(totalItems); - let seeking = new EmptyObject(); + let seeking = Object.create(null); for (let i = 0; i < totalItems; i++) { let pendingItem = pendingFetchItems[i]; @@ -880,7 +879,7 @@ Store = Service.extend({ function handleFoundRecords(foundInternalModels, expectedInternalModels) { // resolve found records - let found = new EmptyObject(); + let found = Object.create(null); for (let i = 0, l = foundInternalModels.length; i < l; i++) { let internalModel = foundInternalModels[i]; let pair = seeking[internalModel.id]; diff --git a/addon/-private/system/store/container-instance-cache.js b/addon/-private/system/store/container-instance-cache.js index ff3edfe0cb2..a1ce4262579 100644 --- a/addon/-private/system/store/container-instance-cache.js +++ b/addon/-private/system/store/container-instance-cache.js @@ -1,6 +1,5 @@ /* global heimdall */ import Ember from 'ember'; -import EmptyObject from "../empty-object"; const { set } = Ember; const { @@ -37,8 +36,8 @@ export default class ContainerInstanceCache { this._owner = owner; this._store = store; this._namespaces = { - adapter: new EmptyObject(), - serializer: new EmptyObject() + adapter: Object.create(null), + serializer: Object.create(null) }; } diff --git a/addon/-private/utils/parse-response-headers.js b/addon/-private/utils/parse-response-headers.js index 5f420d595c0..b63512e3ae9 100644 --- a/addon/-private/utils/parse-response-headers.js +++ b/addon/-private/utils/parse-response-headers.js @@ -1,9 +1,7 @@ -import EmptyObject from '../system/empty-object'; - const CLRF = '\u000d\u000a'; export default function parseResponseHeaders(headersString) { - let headers = new EmptyObject(); + let headers = Object.create(null); if (!headersString) { return headers; diff --git a/tests/unit/utils/parse-response-headers-test.js b/tests/unit/utils/parse-response-headers-test.js index 98adef7bd14..c313713b293 100644 --- a/tests/unit/utils/parse-response-headers-test.js +++ b/tests/unit/utils/parse-response-headers-test.js @@ -1,4 +1,3 @@ -import EmptyObject from 'ember-data/-private/system/empty-object'; import parseResponseHeaders from 'ember-data/-private/utils/parse-response-headers'; import { module, test } from 'qunit'; @@ -9,7 +8,7 @@ module('unit/adapters/parse-response-headers'); test('returns an EmptyObject when headersString is undefined', function(assert) { let headers = parseResponseHeaders(undefined); - assert.deepEqual(headers, new EmptyObject(), 'EmptyObject is returned'); + assert.deepEqual(headers, Object.create(null), 'EmptyObject is returned'); }); test('header parsing', function(assert) {