Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Ember.assign over Ember.merge when possible #153

Merged
merged 1 commit into from Apr 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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