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

[BUGFIX] remove usage of Ember.EXTEND_PROTOTYPES #810

Merged
merged 1 commit into from
May 29, 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
36 changes: 9 additions & 27 deletions ember_debug/adapters/web-extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,12 @@ export default BasicAdapter.extend({
}, null, 'ember-inspector');
},

sendMessage(options) {
options = options || {};
sendMessage(options = {}) {
// If prototype extensions are disabled, `Ember.A()` arrays
// would not be considered native arrays, so it's not possible to
// "clone" them through postMessage unless they are converted to a
// native array.
if (!Ember.EXTEND_PROTOTYPES || Ember.EXTEND_PROTOTYPES.Array === false) {
options = deepCloneArrays(deepClone(options));
}
options = deepClone(options);
this.get('_chromePort').postMessage(options);
},

Expand Down Expand Up @@ -78,33 +75,18 @@ export default BasicAdapter.extend({
* @param {Mixed} item The item to clone
* @return {Mixed}
*/
function deepCloneArrays(item) {
function deepClone(item) {
let clone = item;
if (isArray(item)) {
item = item.slice();
clone = new Array(item.length);
item.forEach((child, key) => {
item[key] = deepCloneArrays(child);
clone[key] = deepClone(child);
});
} else if (item && typeOf(item) === 'object') {
clone = {};
keys(item).forEach(key => {
item[key] = deepCloneArrays(item[key]);
clone[key] = deepClone(item[key]);
});
}
return item;
}

/**
* Recursive function that performs a deep clone on an object.
*
* @param {Any} obj
* @return {Any} Deep cloned object
*/
function deepClone(obj) {
if (obj && typeOf(obj) === 'object') {
let item = {};
keys(obj).forEach(key => {
item[key] = deepClone(obj[key]);
});
return item;
}
return obj;
return clone;
}
3 changes: 1 addition & 2 deletions ember_debug/adapters/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import { onReady } from '../utils/on-ready';

export default BasicAdapter.extend({

sendMessage(options) {
options = options || {};
sendMessage(options = {}) {
this.get('socket').emit('emberInspectorMessage', options);
},

Expand Down