Skip to content

Commit

Permalink
Don’t crash \w Ember 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanpenner committed Aug 20, 2015
1 parent d473181 commit e47e9b6
Show file tree
Hide file tree
Showing 24 changed files with 61 additions and 33 deletions.
3 changes: 2 additions & 1 deletion packages/ember-data/lib/adapters/errors.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { forEach } from 'ember-data/ext/ember/array';

const EmberError = Ember.Error;
const forEach = Ember.ArrayPolyfills.forEach;
const SOURCE_POINTER_REGEXP = /^\/?data\/(attributes|relationships)\/(.*)/;

import {
Expand Down
4 changes: 3 additions & 1 deletion packages/ember-data/lib/adapters/fixture-adapter.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import ArrayPolyfills from 'ember-data/ext/ember/array';
/**
@module ember-data
*/
var get = Ember.get;
var fmt = Ember.String.fmt;
var indexOf = Ember.ArrayPolyfills.indexOf;

var indexOf = ArrayPolyfills.indexOf;

var counter = 0;

Expand Down
4 changes: 3 additions & 1 deletion packages/ember-data/lib/adapters/rest-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ import {
import {
MapWithDefault
} from "ember-data/system/map";
import ArrayPolyfills from 'ember-data/ext/ember/array';

var get = Ember.get;
var set = Ember.set;
var forEach = Ember.ArrayPolyfills.forEach;
var forEach = ArrayPolyfills.forEach;

import {
create,
Expand Down
2 changes: 2 additions & 0 deletions packages/ember-data/lib/ext/ember/array.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Ember from 'ember';
export default (Array.prorotype || Ember.ArrayPolyfills);

This comment has been minimized.

Copy link
@workmanw

workmanw Aug 21, 2015

:( This typo causes v1.13.10 to crash w/ Ember 2.0. It should be Array.prototype.

This comment has been minimized.

Copy link
@workmanw

workmanw Aug 21, 2015

Opened #3685.

Empty file.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import ArrayPolyfills from 'ember-data/ext/ember/array';

var get = Ember.get;
var set = Ember.set;
var forEach = Ember.ArrayPolyfills.forEach;
var forEach = ArrayPolyfills.forEach;
var camelize = Ember.String.camelize;

/**
Expand Down
3 changes: 1 addition & 2 deletions packages/ember-data/lib/serializers/json-api-serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
import JSONSerializer from 'ember-data/serializers/json-serializer';
import normalizeModelName from 'ember-data/system/normalize-model-name';
import { pluralize, singularize } from 'ember-inflector/lib/system/string';
import { map } from "ember-data/ext/ember/enumerable-utils";

var dasherize = Ember.String.dasherize;
var get = Ember.get;
var map = Ember.ArrayPolyfills.map;

/**
Ember Data 2.0 Serializer:
Expand Down
3 changes: 2 additions & 1 deletion packages/ember-data/lib/serializers/json-serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import coerceId from "ember-data/system/coerce-id";
import normalizeModelName from "ember-data/system/normalize-model-name";

import { errorsArrayToHash } from "ember-data/adapters/errors";
import ArrayPolyfills from 'ember-data/ext/ember/array';

var get = Ember.get;
var isNone = Ember.isNone;
var map = Ember.ArrayPolyfills.map;
var map = ArrayPolyfills.map;
var merge = Ember.merge;

/**
Expand Down
5 changes: 3 additions & 2 deletions packages/ember-data/lib/serializers/rest-serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import normalizeModelName from "ember-data/system/normalize-model-name";
import {singularize} from "ember-inflector/lib/system/string";
import coerceId from "ember-data/system/coerce-id";
import { pushPayload } from "ember-data/system/store/serializer-response";
import ArrayPolyfills from 'ember-data/ext/ember/array';

import {
keysFunc
} from 'ember-data/system/object-polyfills';

var forEach = Ember.ArrayPolyfills.forEach;
var map = Ember.ArrayPolyfills.map;
var forEach = ArrayPolyfills.forEach;
var map = ArrayPolyfills.map;
var camelize = Ember.String.camelize;
var get = Ember.get;

Expand Down
5 changes: 3 additions & 2 deletions packages/ember-data/lib/system/many-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
@module ember-data
*/
import { PromiseArray } from "ember-data/system/promise-proxies";
import ArrayPolyfills from 'ember-data/ext/ember/array';

var get = Ember.get;
var set = Ember.set;
var filter = Ember.ArrayPolyfills.filter;
var filter = ArrayPolyfills.filter;

/**
A `ManyArray` is a `MutableArray` that represents the contents of a has-many
Expand Down Expand Up @@ -192,7 +193,7 @@ export default Ember.Object.extend(Ember.MutableArray, Ember.Evented, {
records = this.currentState.slice(idx, idx+amt);
this.get('relationship').removeRecords(records);
}
var map = objects.map || Ember.ArrayPolyfills.map;
var map = objects.map || ArrayPolyfills.map;
if (objects) {
this.get('relationship').addRecords(map.call(objects, function(obj) { return obj._internalModel; }), idx);
}
Expand Down
3 changes: 2 additions & 1 deletion packages/ember-data/lib/system/model/errors.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
var get = Ember.get;
var set = Ember.set;
var isEmpty = Ember.isEmpty;
var map = Ember.ArrayPolyfills.map;
var makeArray = Ember.makeArray;
import ArrayPolyfills from 'ember-data/ext/ember/array';
var map = ArrayPolyfills.map;

import {
MapWithDefault
Expand Down
6 changes: 4 additions & 2 deletions packages/ember-data/lib/system/model/internal-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import merge from "ember-data/system/merge";
import RootState from "ember-data/system/model/states";
import Relationships from "ember-data/system/relationships/state/create";
import Snapshot from "ember-data/system/snapshot";
import ArrayPolyfills from 'ember-data/ext/ember/array';

import {
create,
Expand All @@ -11,8 +12,9 @@ import {
var Promise = Ember.RSVP.Promise;
var get = Ember.get;
var set = Ember.set;
var forEach = Ember.ArrayPolyfills.forEach;
var map = Ember.ArrayPolyfills.map;

var forEach = ArrayPolyfills.forEach;
var map = ArrayPolyfills.map;

var _extractPivotNameCache = create(null);
var _splitOnDotCache = create(null);
Expand Down
5 changes: 3 additions & 2 deletions packages/ember-data/lib/system/model/model.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { PromiseObject } from "ember-data/system/promise-proxies";
import Errors from "ember-data/system/model/errors";
import ArrayPolyfills from 'ember-data/ext/ember/array';

import {
create,
Expand All @@ -14,10 +15,10 @@ var errorDeprecationShown = false;
*/

var get = Ember.get;
var forEach = Ember.ArrayPolyfills.forEach;
var indexOf = Ember.ArrayPolyfills.indexOf;
var merge = Ember.merge;
var copy = Ember.copy;
var forEach = ArrayPolyfills.forEach;
var indexOf = ArrayPolyfills.indexOf;

function intersection (array1, array2) {
var result = [];
Expand Down
6 changes: 4 additions & 2 deletions packages/ember-data/lib/system/record-array-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ import {
MapWithDefault
} from "ember-data/system/map";
import OrderedSet from "ember-data/system/ordered-set";
import ArrayPolyfills from 'ember-data/ext/ember/array';

var get = Ember.get;
var forEach = Ember.ArrayPolyfills.forEach;
var indexOf = Ember.ArrayPolyfills.indexOf;
var forEach = ArrayPolyfills.forEach;
var indexOf = ArrayPolyfills.indexOf;

/**
@class RecordArrayManager
Expand Down
3 changes: 2 additions & 1 deletion packages/ember-data/lib/system/relationships/ext.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import {
Map,
MapWithDefault
} from "ember-data/system/map";
import ArrayPolyfills from 'ember-data/ext/ember/array';

import {
create
} from 'ember-data/system/object-polyfills';

var get = Ember.get;
var filter = Ember.ArrayPolyfills.filter;
var filter = ArrayPolyfills.filter;

var relationshipsDescriptor = Ember.computed(function() {
if (Ember.testing === true && relationshipsDescriptor._cacheable === true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { PromiseManyArray } from "ember-data/system/promise-proxies";
import Relationship from "ember-data/system/relationships/state/relationship";
import OrderedSet from "ember-data/system/ordered-set";
import ManyArray from "ember-data/system/many-array";
import ArrayPolyfills from 'ember-data/ext/ember/array';

import { assertPolymorphicType } from "ember-data/utils";

import {
create
} from 'ember-data/system/object-polyfills';

var map = Ember.ArrayPolyfills.map;

var map = ArrayPolyfills.map;

var ManyRelationship = function(store, record, inverseKey, relationshipMeta) {
this._super$constructor(store, record, inverseKey, relationshipMeta);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import OrderedSet from "ember-data/system/ordered-set";
import ArrayPolyfills from 'ember-data/ext/ember/array';

var forEach = Ember.ArrayPolyfills.forEach;
var forEach = ArrayPolyfills.forEach;

function Relationship(store, record, inverseKey, relationshipMeta) {
this.members = new OrderedSet();
Expand Down
9 changes: 5 additions & 4 deletions packages/ember-data/lib/system/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import RecordArrayManager from "ember-data/system/record-array-manager";
import ContainerInstanceCache from 'ember-data/system/store/container-instance-cache';

import InternalModel from "ember-data/system/model/internal-model";
import ArrayPolyfills from 'ember-data/ext/ember/array';

import {
create,
Expand Down Expand Up @@ -112,9 +113,10 @@ var get = Ember.get;
var set = Ember.set;
var once = Ember.run.once;
var isNone = Ember.isNone;
var forEach = Ember.ArrayPolyfills.forEach;
var indexOf = Ember.ArrayPolyfills.indexOf;
var map = Ember.ArrayPolyfills.map;
var forEach = ArrayPolyfills.forEach;
var indexOf = ArrayPolyfills.indexOf;
var map = ArrayPolyfills.map;
var filter = ArrayPolyfills.filter;
var Promise = Ember.RSVP.Promise;
var copy = Ember.copy;
var Store;
Expand Down Expand Up @@ -1922,7 +1924,6 @@ Store = Service.extend({
Ember.assert(`You tried to push data with a type '${modelName}' but no model could be found with that name.`, this._hasModelFor(modelName));

var type = this.modelFor(modelName);
var filter = Ember.ArrayPolyfills.filter;

// If Ember.ENV.DS_WARN_ON_UNKNOWN_KEYS is set to true and the payload
// contains unknown keys, log a warning.
Expand Down
3 changes: 2 additions & 1 deletion packages/ember-data/lib/system/store/finders.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import {
import {
serializerForAdapter
} from "ember-data/system/store/serializers";
import ArrayPolyfills from 'ember-data/ext/ember/array';

var Promise = Ember.RSVP.Promise;
var map = Ember.ArrayPolyfills.map;
var map = ArrayPolyfills.map;
var get = Ember.get;

export function _find(adapter, store, typeClass, id, internalModel, options) {
Expand Down
5 changes: 3 additions & 2 deletions packages/ember-data/lib/system/store/serializer-response.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import Model from 'ember-data/system/model/model';
import ArrayPolyfills from 'ember-data/ext/ember/array';

import {
keysFunc
} from 'ember-data/system/object-polyfills';

var forEach = Ember.ArrayPolyfills.forEach;
var map = Ember.ArrayPolyfills.map;
var forEach = ArrayPolyfills.forEach;
var map = ArrayPolyfills.map;
var get = Ember.get;

/**
Expand Down
5 changes: 3 additions & 2 deletions packages/ember-data/tests/integration/filter-test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import customAdapter from 'ember-data/tests/helpers/custom-adapter';
import ArrayPolyfills from 'ember-data/ext/ember/array';

var get = Ember.get;
var set = Ember.set;
var forEach = Ember.ArrayPolyfills.forEach;
var indexOf = Ember.ArrayPolyfills.indexOf;
var forEach = ArrayPolyfills.forEach;
var indexOf = ArrayPolyfills.indexOf;
var run = Ember.run;

var Person, store, env, array, recordArray;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import ArrayPolyfills from 'ember-data/ext/ember/array';

var get = Ember.get;
var HomePlanet, SuperVillain, EvilMinion, SecretLab, SecretWeapon, BatCave, Comment,
league, superVillain, evilMinion, secretWeapon, homePlanet, secretLab, env;
var indexOf = Ember.ArrayPolyfills.indexOf;

var indexOf = ArrayPolyfills.indexOf;
var run = Ember.run;
var LightSaber;

Expand Down
3 changes: 2 additions & 1 deletion packages/ember-data/tests/unit/store/push-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ var attr = DS.attr;
var hasMany = DS.hasMany;
var belongsTo = DS.belongsTo;
var run = Ember.run;
var forEach = Ember.ArrayPolyfills.forEach;
import ArrayPolyfills from 'ember-data/ext/ember/array';
var forEach = ArrayPolyfills.forEach;

module("unit/store/push - DS.Store#push", {
setup: function() {
Expand Down
1 change: 1 addition & 0 deletions packages/ember/lib/main.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// Shim Ember module

export default Ember;

0 comments on commit e47e9b6

Please sign in to comment.