Skip to content

Commit

Permalink
Merge pull request #153 from martndemus/use-assign-over-merge
Browse files Browse the repository at this point in the history
Use Ember.assign over Ember.merge when possible
  • Loading branch information
hhff committed Apr 12, 2016
2 parents 2b4088a + adefbe9 commit 107a34d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 3 additions & 2 deletions addon/mixins/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Ember from 'ember';
import { emberDataVersionIs } from 'ember-version-is';

const keys = Object.keys || Ember.keys;
const assign = Ember.assign || Ember.merge;
/**
The Ember Infinity Route Mixin enables an application route to load paginated
records for the route `model` as triggered by the controller (or Infinity Loader
Expand Down Expand Up @@ -174,7 +175,7 @@ const RouteMixin = Ember.Mixin.create({

this._ensureCompatibility();

options = options ? Ember.merge({}, options) : {};
options = options ? assign({}, options) : {};
const startingPage = options.startingPage === undefined ? 0 : options.startingPage-1;

const perPage = options.perPage || this.get('_perPage');
Expand Down Expand Up @@ -283,7 +284,7 @@ const RouteMixin = Ember.Mixin.create({
pageParams[this.get('perPageParam')] = this.get('_perPage');
pageParams[this.get('pageParam')] = nextPage;

const params = Ember.merge(pageParams, this.get('_extraParams'));
const params = assign(pageParams, this.get('_extraParams'));

const boundParams = this.get('_boundParams');
if (!Ember.isEmpty(boundParams)) {
Expand Down
6 changes: 4 additions & 2 deletions tests/helpers/start-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import Ember from 'ember';
import Application from '../../app';
import config from '../../config/environment';

const assign = Ember.assign || Ember.merge;

export default function startApp(attrs) {
let application;

let attributes = Ember.merge({}, config.APP);
attributes = Ember.merge(attributes, attrs); // use defaults, but you can override;
let attributes = assign({}, config.APP);
attributes = assign(attributes, attrs); // use defaults, but you can override;

Ember.run(() => {
application = Application.create(attributes);
Expand Down
4 changes: 3 additions & 1 deletion tests/unit/mixins/route-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { module, test } from 'qunit';

module('RouteMixin');

const assign = Ember.assign || Ember.merge;

let EO = Ember.Object.create.bind(Ember.Object);
let EA = function (content, meta={}) {
return Ember.ArrayProxy.create({ content: Ember.A(content), meta });
Expand All @@ -16,7 +18,7 @@ test('it works', assert => {
});

function createRoute(infinityModelArgs, routeProperties={}) {
var RouteObject = Ember.Route.extend(RouteMixin, Ember.merge(routeProperties, {
var RouteObject = Ember.Route.extend(RouteMixin, assign(routeProperties, {
model() {
return this.infinityModel(...infinityModelArgs);
}
Expand Down

0 comments on commit 107a34d

Please sign in to comment.