Skip to content

Commit

Permalink
[CLEANUP] drop IE8 support
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanpenner committed Jun 16, 2015
1 parent 0948b3a commit 735ae3f
Show file tree
Hide file tree
Showing 41 changed files with 328 additions and 555 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"broccoli-file-creator": "^0.1.0",
"broccoli-file-mover": "~0.2.0",
"broccoli-jscs": "0.0.22",
"broccoli-jshint": "^0.5.1",
"broccoli-jshint": "^0.5.6",
"broccoli-merge-trees": "^0.1.4",
"broccoli-render-template": "0.0.3",
"broccoli-replace": "~0.2.0",
Expand Down
4 changes: 1 addition & 3 deletions packages/ember-data/lib/adapters/build-url-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var get = Ember.get;
@class BuildURLMixin
@namespace DS
*/
var BuildURLMixin = Ember.Mixin.create({
export default Ember.Mixin.create({
/**
Builds a URL for a given type and optional ID.
Expand Down Expand Up @@ -313,5 +313,3 @@ function urlForFindQuery(query, modelName) {
Ember.deprecate('BuildURLMixin#urlForFindQuery has been deprecated and renamed to `urlForQuery`.');
return this._buildURL(modelName);
}

export default BuildURLMixin;
51 changes: 14 additions & 37 deletions packages/ember-data/lib/adapters/fixture-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/
var get = Ember.get;
var fmt = Ember.String.fmt;
var indexOf = Ember.ArrayPolyfills.indexOf;

var counter = 0;

Expand Down Expand Up @@ -65,8 +64,7 @@ export default Adapter.extend({
*/
fixturesForType: function(typeClass) {
if (typeClass.FIXTURES) {
var fixtures = Ember.A(typeClass.FIXTURES);
return fixtures.map(function(fixture) {
return typeClass.FIXTURES.map((fixture) => {
var fixtureIdType = typeof fixture.id;
if (fixtureIdType !== "number" && fixtureIdType !== "string") {
throw new Error(fmt('the id property must be defined as a number or string for fixture %@', [fixture]));
Expand Down Expand Up @@ -148,9 +146,7 @@ export default Adapter.extend({
}

if (fixture) {
return this.simulateRemoteCall(function() {
return fixture;
}, this);
return this.simulateRemoteCall(() => fixture);
}
},

Expand All @@ -168,15 +164,11 @@ export default Adapter.extend({
Ember.assert("Unable to find fixtures for model type "+typeClass.toString(), fixtures);

if (fixtures) {
fixtures = fixtures.filter(function(item) {
return indexOf.call(ids, item.id) !== -1;
});
fixtures = fixtures.filter((item) => ids.indexOf(item.id) !== -1);
}

if (fixtures) {
return this.simulateRemoteCall(function() {
return fixtures;
}, this);
return this.simulateRemoteCall(() => fixtures);
}
},

Expand All @@ -192,9 +184,7 @@ export default Adapter.extend({

Ember.assert("Unable to find fixtures for model type "+typeClass.toString(), fixtures);

return this.simulateRemoteCall(function() {
return fixtures;
}, this);
return this.simulateRemoteCall(() => fixtures);
},

/**
Expand All @@ -214,9 +204,7 @@ export default Adapter.extend({
fixtures = this.queryFixtures(fixtures, query, typeClass);

if (fixtures) {
return this.simulateRemoteCall(function() {
return fixtures;
}, this);
return this.simulateRemoteCall(() => fixtures);
}
},

Expand All @@ -232,9 +220,7 @@ export default Adapter.extend({

this.updateFixtures(typeClass, fixture);

return this.simulateRemoteCall(function() {
return fixture;
}, this);
return this.simulateRemoteCall(() => fixture);
},

/**
Expand All @@ -249,9 +235,7 @@ export default Adapter.extend({

this.updateFixtures(typeClass, fixture);

return this.simulateRemoteCall(function() {
return fixture;
}, this);
return this.simulateRemoteCall(() => fixture);
},

/**
Expand All @@ -264,10 +248,7 @@ export default Adapter.extend({
deleteRecord: function(store, typeClass, snapshot) {
this.deleteLoadedFixture(typeClass, snapshot);

return this.simulateRemoteCall(function() {
// no payload in a deletion
return null;
});
return this.simulateRemoteCall(() => null);
},

/*
Expand All @@ -280,7 +261,7 @@ export default Adapter.extend({
var existingFixture = this.findExistingFixture(typeClass, snapshot);

if (existingFixture) {
var index = indexOf.call(typeClass.FIXTURES, existingFixture);
var index = typeClass.FIXTURES.indexOf(existingFixture);
typeClass.FIXTURES.splice(index, 1);
return true;
}
Expand All @@ -306,7 +287,7 @@ export default Adapter.extend({
@param id
*/
findFixtureById: function(fixtures, id) {
return Ember.A(fixtures).find(function(r) {
return Ember.A(fixtures).find((r) => {
if (''+get(r, 'id') === ''+id) {
return true;
} else {
Expand All @@ -324,18 +305,14 @@ export default Adapter.extend({
simulateRemoteCall: function(callback, context) {
var adapter = this;

return new Ember.RSVP.Promise(function(resolve) {
return new Ember.RSVP.Promise((resolve) => {
var value = Ember.copy(callback.call(context), true);
if (get(adapter, 'simulateRemoteResponse')) {
// Schedule with setTimeout
Ember.run.later(function() {
resolve(value);
}, get(adapter, 'latency'));
Ember.run.later(() => resolve(value), get(adapter, 'latency'));
} else {
// Asynchronous, but at the of the runloop with zero latency
Ember.run.schedule('actions', null, function() {
resolve(value);
});
Ember.run.schedule('actions', null, () => resolve(value));
}
}, "DS: FixtureAdapter#simulateRemoteCall");
}
Expand Down
51 changes: 22 additions & 29 deletions packages/ember-data/lib/adapters/rest-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
} from "ember-data/system/map";
var get = Ember.get;
var set = Ember.set;
var forEach = Ember.ArrayPolyfills.forEach;

import BuildURLMixin from "ember-data/adapters/build-url-mixin";

Expand Down Expand Up @@ -183,7 +182,7 @@ import BuildURLMixin from "ember-data/adapters/build-url-mixin";
@extends DS.Adapter
@uses DS.BuildURLMixin
*/
var RestAdapter = Adapter.extend(BuildURLMixin, {
var RESTAdapter = Adapter.extend(BuildURLMixin, {
defaultSerializer: '-rest',

/**
Expand Down Expand Up @@ -228,7 +227,7 @@ var RestAdapter = Adapter.extend(BuildURLMixin, {
@return {Object}
*/
sortQueryParams: function(obj) {
var keys = Ember.keys(obj);
var keys = Object.keys(obj);
var len = keys.length;
if (len < 2) {
return obj;
Expand Down Expand Up @@ -379,7 +378,7 @@ var RestAdapter = Adapter.extend(BuildURLMixin, {
@return {Promise} promise
*/
findRecord: function(store, type, id, snapshot) {
var find = RestAdapter.prototype.find;
var find = RESTAdapter.prototype.find;
if (find !== this.find) {
Ember.deprecate('RestAdapter#find has been deprecated and renamed to `findRecord`.');
return this.find(store, type, id, snapshot);
Expand Down Expand Up @@ -460,7 +459,7 @@ var RestAdapter = Adapter.extend(BuildURLMixin, {
@return {Promise} promise
*/
query: function(store, type, query) {
var findQuery = RestAdapter.prototype.findQuery;
var findQuery = RESTAdapter.prototype.findQuery;
if (findQuery !== this.findQuery) {
Ember.deprecate('RestAdapter#findQuery has been deprecated and renamed to `query`.');
return this.findQuery(store, type, query);
Expand Down Expand Up @@ -702,7 +701,7 @@ var RestAdapter = Adapter.extend(BuildURLMixin, {
var adapter = this;
var maxURLLength = this.maxURLLength;

forEach.call(snapshots, function(snapshot) {
snapshots.forEach((snapshot) => {
var baseUrl = adapter._stripIDFromURL(store, snapshot);
groups.get(baseUrl).push(snapshot);
});
Expand All @@ -712,7 +711,7 @@ var RestAdapter = Adapter.extend(BuildURLMixin, {
var idsSize = 0;
var splitGroups = [[]];

forEach.call(group, function(snapshot) {
group.forEach((snapshot) => {
var additionalLength = encodeURIComponent(snapshot.id).length + paramNameLength;
if (baseUrl.length + idsSize + additionalLength >= maxURLLength) {
idsSize = 0;
Expand All @@ -729,13 +728,11 @@ var RestAdapter = Adapter.extend(BuildURLMixin, {
}

var groupsArray = [];
groups.forEach(function(group, key) {
groups.forEach((group, key) => {
var paramNameLength = '&ids%5B%5D='.length;
var splitGroups = splitGroupToFitInUrl(group, maxURLLength, paramNameLength);

forEach.call(splitGroups, function(splitGroup) {
groupsArray.push(splitGroup);
});
splitGroups.forEach((splitGroup) => groupsArray.push(splitGroup));
});

return groupsArray;
Expand Down Expand Up @@ -897,9 +894,7 @@ var RestAdapter = Adapter.extend(BuildURLMixin, {
var headers = get(this, 'headers');
if (headers !== undefined) {
hash.beforeSend = function (xhr) {
forEach.call(Ember.keys(headers), function(key) {
xhr.setRequestHeader(key, headers[key]);
});
Object.keys(headers).forEach((key) => xhr.setRequestHeader(key, headers[key]));
};
}

Expand All @@ -916,19 +911,17 @@ function endsWith(string, suffix) {
}
}

if (Ember.platform.hasPropertyAccessors) {
Ember.defineProperty(RestAdapter.prototype, 'maxUrlLength', {
enumerable: false,
get: function() {
Ember.deprecate('maxUrlLength has been deprecated (wrong casing). You should use maxURLLength instead.');
return this.maxURLLength;
},

set: function(value) {
Ember.deprecate('maxUrlLength has been deprecated (wrong casing). You should use maxURLLength instead.');
set(this, 'maxURLLength', value);
}
});
}
Object.defineProperty(RESTAdapter.prototype, 'maxUrlLength', {
enumerable: false,
get: function() {
Ember.deprecate('maxUrlLength has been deprecated (wrong casing). You should use maxURLLength instead.');
return this.maxURLLength;
},

set: function(value) {
Ember.deprecate('maxUrlLength has been deprecated (wrong casing). You should use maxURLLength instead.');
set(this, 'maxURLLength', value);
}
});

export default RestAdapter;
export default RESTAdapter;
26 changes: 9 additions & 17 deletions packages/ember-data/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ if (Ember.VERSION.match(/^1\.12\.0/)) {
throw new Ember.Error("Ember Data does not work with Ember 1.12.0. Please upgrade to Ember 1.12.1 or higher.");
}

// support RSVP 2.x via resolve, but prefer RSVP 3.x's Promise.cast
Ember.RSVP.Promise.cast = Ember.RSVP.Promise.cast || Ember.RSVP.resolve;


import DS from "ember-data/core";
import "ember-data/ext/date";

Expand Down Expand Up @@ -159,7 +155,7 @@ DS.ContainerProxy = ContainerProxy;

DS._setupContainer = setupContainer;

Ember.defineProperty(DS, 'normalizeModelName', {
Object.defineProperty(DS, 'normalizeModelName', {
enumerable: true,
writable: false,
configurable: false,
Expand All @@ -168,19 +164,15 @@ Ember.defineProperty(DS, 'normalizeModelName', {

var fixtureAdapterWasDeprecated = false;

if (Ember.platform.hasPropertyAccessors) {
Ember.defineProperty(DS, 'FixtureAdapter', {
get: function() {
if (!fixtureAdapterWasDeprecated) {
Ember.deprecate('DS.FixtureAdapter has been deprecated and moved into an unsupported addon: https://github.com/emberjs/ember-data-fixture-adapter/tree/master');
fixtureAdapterWasDeprecated = true;
}
return FixtureAdapter;
Object.defineProperty(DS, 'FixtureAdapter', {
get: function() {
if (!fixtureAdapterWasDeprecated) {
Ember.deprecate('DS.FixtureAdapter has been deprecated and moved into an unsupported addon: https://github.com/emberjs/ember-data-fixture-adapter/tree/master');
fixtureAdapterWasDeprecated = true;
}
});
} else {
DS.FixtureAdapter = FixtureAdapter;
}
return FixtureAdapter;
}
});

Ember.lookup.DS = DS;

Expand Down
Loading

0 comments on commit 735ae3f

Please sign in to comment.