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

Deprecate Ember.merge #16956

Merged
merged 4 commits into from
Sep 10, 2018
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
1 change: 1 addition & 0 deletions packages/@ember/deprecated-features/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ export const ARRAY_AT_EACH = !!'3.1.0-beta.1';
export const TARGET_OBJECT = !!'2.18.0-beta.1';
export const MAP = !!'3.3.0-beta.1';
export const ORDERED_SET = !!'3.3.0-beta.1';
export const MERGE = !!'3.6.0-beta.1';
7 changes: 6 additions & 1 deletion packages/@ember/polyfills/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import { MERGE } from '@ember/deprecated-features';
import { default as deprecatedMerge } from './lib/merge';

let merge = MERGE ? deprecatedMerge : undefined;

// Export `assignPolyfill` for testing
export { default as assign, assign as assignPolyfill } from './lib/assign';
export { default as merge } from './lib/merge';
export { merge };
8 changes: 8 additions & 0 deletions packages/@ember/polyfills/lib/merge.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { deprecate } from '@ember/debug';

/**
@module @ember/polyfills
*/
Expand Down Expand Up @@ -25,6 +27,12 @@ export default function merge<T, U>(original: T, updates: U): T & U;
@public
*/
export default function merge(original: object, updates: object) {
deprecate('Use of `merge` has been deprecated. Please use `assign` instead.', false, {
id: 'ember-polyfills.deprecate-merge',
until: '4.0.0',
url: 'https://emberjs.com/deprecations/v3.x/#toc_ember-polyfills-deprecate-merge',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this created yet? Can you link me to the deprecation app PR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not created yet. I need to look into what I need to do for that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

});

if (updates === null || typeof updates !== 'object') {
return original;
}
Expand Down
21 changes: 21 additions & 0 deletions packages/@ember/polyfills/tests/merge_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { merge } from '..';
import { moduleFor, AbstractTestCase } from 'internal-test-helpers';

moduleFor(
'Ember.merge',
class extends AbstractTestCase {
['@test merging objects'](assert) {
let src1 = { a: 1 };
let src2 = { b: 2 };
expectDeprecation(() => {
merge(src1, src2);
}, 'Use of `merge` has been deprecated. Please use `assign` instead.');

assert.deepEqual(
src1,
{ a: 1, b: 2 },
'merge copies values from second source object to first object'
);
}
}
);
12 changes: 5 additions & 7 deletions packages/internal-test-helpers/lib/system/synthetic-events.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { run } from '@ember/runloop';
/* globals Element */

import { merge } from '@ember/polyfills';
import { assign } from '@ember/polyfills';

const DEFAULT_EVENT_OPTIONS = { canBubble: true, cancelable: true };
const KEYBOARD_EVENT_TYPES = ['keydown', 'keypress', 'keyup'];
Expand Down Expand Up @@ -112,7 +112,7 @@ export function fireEvent(element, type, options = {}) {
clientX: x,
clientY: y,
};
event = buildMouseEvent(type, merge(simulatedCoordinates, options));
event = buildMouseEvent(type, assign(simulatedCoordinates, options));
} else {
event = buildBasicEvent(type, options);
}
Expand All @@ -124,16 +124,15 @@ export function fireEvent(element, type, options = {}) {
function buildBasicEvent(type, options = {}) {
let event = document.createEvent('Events');
event.initEvent(type, true, true);
merge(event, options);
assign(event, options);
return event;
}

function buildMouseEvent(type, options = {}) {
let event;
try {
event = document.createEvent('MouseEvents');
let eventOpts = merge({}, DEFAULT_EVENT_OPTIONS);
merge(eventOpts, options);
let eventOpts = assign({}, DEFAULT_EVENT_OPTIONS, options);

event.initMouseEvent(
type,
Expand Down Expand Up @@ -162,8 +161,7 @@ function buildKeyboardEvent(type, options = {}) {
let event;
try {
event = document.createEvent('KeyEvents');
let eventOpts = merge({}, DEFAULT_EVENT_OPTIONS);
merge(eventOpts, options);
let eventOpts = assign({}, DEFAULT_EVENT_OPTIONS, options);
event.initKeyEvent(
type,
eventOpts.canBubble,
Expand Down