Use Object.assign instead of shallowMerge

This commit is contained in:
tophf 2017-03-15 14:58:59 +03:00
parent 913df00f35
commit 34cd025487
4 changed files with 3 additions and 15 deletions

View File

@ -20,7 +20,6 @@ globals:
prefs: false prefs: false
reportError: true reportError: true
getActiveTab: true getActiveTab: true
shallowMerge: true
t: true t: true
getCodeMirrorThemes: true getCodeMirrorThemes: true
setupLivePrefs: true setupLivePrefs: true

View File

@ -130,7 +130,7 @@ function initCodeMirror() {
var isWindowsOS = navigator.appVersion.indexOf("Windows") > 0; var isWindowsOS = navigator.appVersion.indexOf("Windows") > 0;
// default option values // default option values
shallowMerge(CM.defaults, { Object.assign(CM.defaults, {
mode: 'css', mode: 'css',
lineNumbers: true, lineNumbers: true,
lineWrapping: true, lineWrapping: true,
@ -1591,7 +1591,7 @@ function showCodeMirrorPopup(title, html, options) {
var popup = showHelp(title, html); var popup = showHelp(title, html);
popup.classList.add("big"); popup.classList.add("big");
popup.codebox = CodeMirror(popup.querySelector(".contents"), shallowMerge({ popup.codebox = CodeMirror(popup.querySelector(".contents"), Object.assign({
mode: "css", mode: "css",
lineNumbers: true, lineNumbers: true,
lineWrapping: true, lineWrapping: true,

View File

@ -14,7 +14,7 @@ function notifyAllTabs(request) {
}); });
}); });
// notify all open popups // notify all open popups
var reqPopup = shallowMerge({}, request, {method: "updatePopup", reason: request.method}); const reqPopup = Object.assign({}, request, {method: 'updatePopup', reason: request.method});
chrome.runtime.sendMessage(reqPopup); chrome.runtime.sendMessage(reqPopup);
// notify self: the message no longer is sent to the origin in new Chrome // notify self: the message no longer is sent to the origin in new Chrome
if (typeof applyOnMessage !== 'undefined') { if (typeof applyOnMessage !== 'undefined') {

View File

@ -521,17 +521,6 @@ function deepMerge(target, obj1 /* plus any number of object arguments */) {
return target; return target;
} }
function shallowMerge(target, obj1 /* plus any number of object arguments */) {
for (var i = 1; i < arguments.length; i++) {
var obj = arguments[i];
for (var k in obj) {
target[k] = obj[k];
// hasOwnProperty checking is not needed for our non-OOP stuff
}
}
return target;
}
function equal(a, b) { function equal(a, b) {
if (!a || !b || typeof a != "object" || typeof b != "object") { if (!a || !b || typeof a != "object" || typeof b != "object") {
return a === b; return a === b;