dist/globals/ember-data.prod.js in ember-data-source-2.14.10 vs dist/globals/ember-data.prod.js in ember-data-source-2.14.11
- old
+ new
@@ -4,20 +4,18 @@
/*!
* @overview Ember Data
* @copyright Copyright 2011-2017 Tilde Inc. and contributors.
* Portions Copyright 2011 LivingSocial Inc.
* @license Licensed under MIT license (see license.js)
- * @version 2.14.10
+ * @version 2.14.11
*/
var loader, define, requireModule, require, requirejs;
(function (global) {
'use strict';
- var heimdall = global.heimdall;
-
function dict() {
var obj = Object.create(null);
obj['__'] = undefined;
delete obj['__'];
return obj;
@@ -55,11 +53,13 @@
global[newName] = global[oldName];
global[oldName] = oldGlobals[oldName];
}
}
}
- }
+ },
+ // Option to enable or disable the generation of default exports
+ makeDefaultExport: true
};
var registry = dict();
var seen = dict();
@@ -105,10 +105,11 @@
// circular dependency so we must return our (partial) exports.
if (this.state === 'finalized' || this.state === 'reifying') {
return this.module.exports;
}
+
if (loader.wrapModules) {
this.callback = loader.wrapModules(this.id, this.callback);
}
this.reify();
@@ -118,11 +119,13 @@
this.state = 'finalized';
if (!(this.hasExportsAsDep && result === undefined)) {
this.module.exports = result;
}
- this.makeDefaultExport();
+ if (loader.makeDefaultExport) {
+ this.makeDefaultExport();
+ }
return this.module.exports;
};
Module.prototype.unsee = function () {
this.state = 'new';
@@ -276,10 +279,11 @@
function resolve(child, id) {
if (child.charAt(0) !== '.') {
return child;
}
+
var parts = child.split('/');
var nameParts = id.split('/');
var parentBase = nameParts.slice(0, -1);
for (var i = 0, l = parts.length; i < l; i++) {
@@ -426,11 +430,11 @@
var assertionMessage = 'You cannot add a record of modelClass \'' + addedModelName + '\' to the \'' + parentModelName + '.' + key + '\' relationship (only \'' + relationshipModelName + '\' allowed)';
assert(assertionMessage, checkPolymorphic(relationshipClass, addedInternalModel.modelClass));
}
});
-define('ember-data/-private/adapters/build-url-mixin', ['exports', 'ember'], function (exports, _ember) {
+define('ember-data/-private/adapters/build-url-mixin', ['exports', 'ember', 'ember-inflector'], function (exports, _ember, _emberInflector) {
'use strict';
exports.__esModule = true;
@@ -826,24 +830,25 @@
### Pathname customization
For example if you have an object LineItem with an
endpoint of "/line_items/".
```app/adapters/application.js
import DS from 'ember-data';
+ import { pluralize } from 'ember-inflector';
export default DS.RESTAdapter.extend({
pathForType: function(modelName) {
var decamelized = Ember.String.decamelize(modelName);
- return Ember.String.pluralize(decamelized);
+ return pluralize(decamelized);
}
});
```
@method pathForType
@param {String} modelName
@return {String} path
**/
pathForType: function (modelName) {
var camelized = _ember.default.String.camelize(modelName);
- return _ember.default.String.pluralize(camelized);
+ return (0, _emberInflector.pluralize)(camelized);
}
});
});
define('ember-data/-private/adapters/errors', ['exports', 'ember', 'ember-data/-private/features'], function (exports, _ember, _features) {
'use strict';
@@ -2801,10 +2806,18 @@
}
}
return true;
}
+ function destroyRelationship(rel) {
+ if (rel._inverseIsAsync()) {
+ rel.removeInternalModelFromInverse(rel.inverseInternalModel);
+ rel.removeInverseRelationships();
+ } else {
+ rel.removeCompletelyFromInverse();
+ }
+ }
// this (and all heimdall instrumentation) will be stripped by a babel transform
// https://github.com/heimdalljs/babel5-plugin-strip-heimdall
var InternalModelReferenceId = 1;
@@ -3017,13 +3030,11 @@
};
InternalModel.prototype._directlyRelatedInternalModels = function _directlyRelatedInternalModels() {
var array = [];
this._relationships.forEach(function (name, rel) {
- var local = rel.members.toArray();
- var server = rel.canonicalMembers.toArray();
- array = array.concat(local, server);
+ array = array.concat(rel.members.list, rel.canonicalMembers.list);
});
return array;
};
InternalModel.prototype._allRelatedInternalModels = function _allRelatedInternalModels() {
@@ -3047,10 +3058,13 @@
}
return array;
};
InternalModel.prototype.unloadRecord = function unloadRecord() {
+ if (this.isDestroyed) {
+ return;
+ }
this.send('unloadRecord');
this.dematerializeRecord();
if (this._scheduledDestroy === null) {
this._scheduledDestroy = run.schedule('destroy', this, '_checkForOrphanedInternalModels');
@@ -3415,48 +3429,37 @@
}
});
};
InternalModel.prototype.destroyRelationships = function destroyRelationships() {
- var _this = this;
-
- this._relationships.forEach(function (name, rel) {
- if (rel._inverseIsAsync()) {
- rel.removeInternalModelFromInverse(_this);
- rel.removeInverseRelationships();
- } else {
- rel.removeCompletelyFromInverse();
- }
+ var relationships = this._relationships;
+ relationships.forEach(function (name, rel) {
+ return destroyRelationship(rel);
});
var implicitRelationships = this._implicitRelationships;
this.__implicitRelationships = null;
Object.keys(implicitRelationships).forEach(function (key) {
var rel = implicitRelationships[key];
- if (rel._inverseIsAsync()) {
- rel.removeInternalModelFromInverse(_this);
- rel.removeInverseRelationships();
- } else {
- rel.removeCompletelyFromInverse();
- }
+ destroyRelationship(rel);
rel.destroy();
});
};
InternalModel.prototype.preloadData = function preloadData(preload) {
- var _this2 = this;
+ var _this = this;
//TODO(Igor) consider the polymorphic case
Object.keys(preload).forEach(function (key) {
var preloadValue = get(preload, key);
- var relationshipMeta = _this2.modelClass.metaForProperty(key);
+ var relationshipMeta = _this.modelClass.metaForProperty(key);
if (relationshipMeta.isRelationship) {
- _this2._preloadRelationship(key, preloadValue);
+ _this._preloadRelationship(key, preloadValue);
} else {
- _this2._data[key] = preloadValue;
+ _this._data[key] = preloadValue;
}
});
};
InternalModel.prototype._preloadRelationship = function _preloadRelationship(key, preloadValue) {
@@ -3656,11 +3659,11 @@
InternalModel.prototype.toString = function toString() {
return '<' + this.modelName + ':' + this.id + '>';
};
InternalModel.prototype.referenceFor = function referenceFor(kind, name) {
- var _this3 = this;
+ var _this2 = this;
var reference = this.references[name];
if (!reference) {
var relationship = this._relationships.get(name);
@@ -8271,11 +8274,17 @@
// }]
//
// Then we will initially have set user:2 as having helicopter:1, which we
// need to remove before adding helicopter:1 to user:4
//
- this._removeInverse(id, previousPayload, inverseIdToPayloads);
+ // only remove relationship information before adding if there is relationshipData.data
+ // * null is considered new information "empty", and it should win
+ // * undefined is NOT considered new information, we should keep original state
+ // * anything else is considered new information, and it should win
+ if (relationshipData.data !== undefined) {
+ this._removeInverse(id, previousPayload, inverseIdToPayloads);
+ }
idToPayloads[id] = relationshipData;
this._populateInverse(relationshipData, inverseRelationshipData, inverseIdToPayloads, inverseIsMany);
}
};
@@ -8985,31 +8994,26 @@
this.addCanonicalInternalModel(internalModel, i);
}
};
ManyRelationship.prototype.setInitialInternalModels = function setInitialInternalModels(internalModels) {
- var _canonicalState;
-
if (Array.isArray(internalModels) === false || internalModels.length === 0) {
return;
}
- var forCanonical = [];
-
for (var i = 0; i < internalModels.length; i++) {
var internalModel = internalModels[i];
if (this.canonicalMembers.has(internalModel)) {
continue;
}
- forCanonical.push(internalModel);
this.canonicalMembers.add(internalModel);
this.members.add(internalModel);
this.setupInverseRelationship(internalModel);
}
- (_canonicalState = this.canonicalState).splice.apply(_canonicalState, [0, this.canonicalState.length].concat(forCanonical));
+ this.canonicalState = this.canonicalMembers.toArray();
};
ManyRelationship.prototype.fetchLink = function fetchLink() {
var _this2 = this;
@@ -9196,25 +9200,24 @@
}
return this.inverseInternalModel._relationships.get(this.inverseKey).isAsync;
};
Relationship.prototype.removeInverseRelationships = function removeInverseRelationships() {
- var _this = this;
-
if (!this.inverseKey) {
return;
}
var allMembers =
// we actually want a union of members and canonicalMembers
// they should be disjoint but currently are not due to a bug
- this.members.toArray().concat(this.canonicalMembers.toArray());
+ this.members.list.concat(this.canonicalMembers.list);
- allMembers.forEach(function (inverseInternalModel) {
- var relationship = inverseInternalModel._relationships.get(_this.inverseKey);
+ for (var i = 0; i < allMembers.length; i++) {
+ var inverseInternalModel = allMembers[i];
+ var relationship = inverseInternalModel._relationships.get(this.inverseKey);
relationship.inverseDidDematerialize();
- });
+ }
};
Relationship.prototype.inverseDidDematerialize = function inverseDidDematerialize() {};
Relationship.prototype.updateMeta = function updateMeta(meta) {
@@ -9235,22 +9238,22 @@
this.removeCanonicalInternalModel(_member);
}
};
Relationship.prototype.removeInternalModels = function removeInternalModels(internalModels) {
- var _this2 = this;
+ var _this = this;
internalModels.forEach(function (internalModel) {
- return _this2.removeInternalModel(internalModel);
+ return _this.removeInternalModel(internalModel);
});
};
Relationship.prototype.addInternalModels = function addInternalModels(internalModels, idx) {
- var _this3 = this;
+ var _this2 = this;
internalModels.forEach(function (internalModel) {
- _this3.addInternalModel(internalModel, idx);
+ _this2.addInternalModel(internalModel, idx);
if (idx !== undefined) {
idx++;
}
});
};
@@ -9376,11 +9379,11 @@
this.canonicalMembers.delete(internalModel);
this.flushCanonicalLater();
};
Relationship.prototype.removeCompletelyFromInverse = function removeCompletelyFromInverse() {
- var _this4 = this;
+ var _this3 = this;
if (!this.inverseKey) {
return;
}
@@ -9391,11 +9394,11 @@
var unload = function (inverseInternalModel) {
var id = guidFor(inverseInternalModel);
if (seen[id] === undefined) {
- var relationship = inverseInternalModel._relationships.get(_this4.inverseKey);
+ var relationship = inverseInternalModel._relationships.get(_this3.inverseKey);
relationship.removeCompletelyFromOwn(internalModel);
seen[id] = true;
}
};
@@ -11562,10 +11565,12 @@
// however, this is more than likely a developer error.
if (oldId !== null && id === null) {
return;
}
+ var existingInternalModel = this._existingInternalModelForId(modelName, id);
+
this._internalModelsFor(internalModel.modelName).set(id, internalModel);
internalModel.setId(id);
},
@@ -12060,28 +12065,31 @@
@param {Object} data
@return {InternalModel} internal model
*/
_buildInternalModel: function (modelName, id, data) {
- var internalModels = this._internalModelsFor(modelName);
- var existingInternalModel = internalModels.get(id);
+ var existingInternalModel = this._existingInternalModelForId(modelName, id);
- if (existingInternalModel && existingInternalModel.hasScheduledDestroy()) {
- // unloadRecord is async, if one attempts to unload + then sync create,
- // we must ensure the unload is complete before starting the create
- existingInternalModel.destroySync();
- existingInternalModel = null;
- }
-
// lookupFactory should really return an object that creates
// instances with the injections applied
var internalModel = new _internalModel5.default(modelName, id, this, data);
- internalModels.add(internalModel, id);
+ this._internalModelsFor(modelName).add(internalModel, id);
return internalModel;
},
+ _existingInternalModelForId: function (modelName, id) {
+ var internalModel = this._internalModelsFor(modelName).get(id);
+
+ if (internalModel && internalModel.hasScheduledDestroy()) {
+ // unloadRecord is async, if one attempts to unload + then sync create,
+ // we must ensure the unload is complete before starting the create
+ internalModel.destroySync();
+ internalModel = null;
+ }
+ return internalModel;
+ },
buildInternalModel: function (modelName, id, data) {
return this._buildInternalModel(modelName, id, data);
},
@@ -13449,11 +13457,11 @@
get: function () {
return _private.errorsArrayToHash;
}
});
});
-define('ember-data/adapters/json-api', ['exports', 'ember', 'ember-data/adapters/rest', 'ember-data/-private'], function (exports, _ember, _rest, _private) {
+define('ember-data/adapters/json-api', ['exports', 'ember', 'ember-inflector', 'ember-data/adapters/rest', 'ember-data/-private'], function (exports, _ember, _emberInflector, _rest, _private) {
'use strict';
exports.__esModule = true;
@@ -13591,10 +13599,15 @@
@class JSONAPIAdapter
@constructor
@namespace DS
@extends DS.RESTAdapter
*/
+ /* global heimdall */
+ /**
+ @module ember-data
+ */
+
var JSONAPIAdapter = _rest.default.extend({
defaultSerializer: '-json-api',
ajaxOptions: function (url, type, options) {
var hash = this._super.apply(this, arguments);
@@ -13669,11 +13682,11 @@
return this.ajax(url, 'GET', { data: { filter: { id: ids.join(',') } } });
}
},
pathForType: function (modelName) {
var dasherized = _ember.default.String.dasherize(modelName);
- return _ember.default.String.pluralize(dasherized);
+ return (0, _emberInflector.pluralize)(dasherized);
},
updateRecord: function (store, type, snapshot) {
if ((0, _private.isEnabled)('ds-improved-ajax') && !this._hasCustomizedAjax()) {
return this._super.apply(this, arguments);
} else {
@@ -13696,14 +13709,11 @@
return true;
}
return false;
}
- }); /* global heimdall */
- /**
- @module ember-data
- */
+ });
if ((0, _private.isEnabled)('ds-improved-ajax')) {
JSONAPIAdapter.reopen({
methodForRequest: function (params) {
@@ -17784,10 +17794,10 @@
});
define("ember-data/version", ["exports"], function (exports) {
"use strict";
exports.__esModule = true;
- exports.default = "2.14.10";
+ exports.default = "2.14.11";
});
define("ember-inflector", ["module", "exports", "ember", "ember-inflector/lib/system", "ember-inflector/lib/ext/string"], function (module, exports, _ember, _system) {
"use strict";
exports.__esModule = true;