From 34cd025487656341b71b33ab5ecb17cd9696336a Mon Sep 17 00:00:00 2001 From: tophf Date: Wed, 15 Mar 2017 14:58:59 +0300 Subject: [PATCH] Use Object.assign instead of shallowMerge --- .eslintrc | 1 - edit.js | 4 ++-- messaging.js | 2 +- storage.js | 11 ----------- 4 files changed, 3 insertions(+), 15 deletions(-) diff --git a/.eslintrc b/.eslintrc index e8aa065e..f71971cd 100644 --- a/.eslintrc +++ b/.eslintrc @@ -20,7 +20,6 @@ globals: prefs: false reportError: true getActiveTab: true - shallowMerge: true t: true getCodeMirrorThemes: true setupLivePrefs: true diff --git a/edit.js b/edit.js index 162f97cd..4b6e9d27 100644 --- a/edit.js +++ b/edit.js @@ -130,7 +130,7 @@ function initCodeMirror() { var isWindowsOS = navigator.appVersion.indexOf("Windows") > 0; // default option values - shallowMerge(CM.defaults, { + Object.assign(CM.defaults, { mode: 'css', lineNumbers: true, lineWrapping: true, @@ -1591,7 +1591,7 @@ function showCodeMirrorPopup(title, html, options) { var popup = showHelp(title, html); popup.classList.add("big"); - popup.codebox = CodeMirror(popup.querySelector(".contents"), shallowMerge({ + popup.codebox = CodeMirror(popup.querySelector(".contents"), Object.assign({ mode: "css", lineNumbers: true, lineWrapping: true, diff --git a/messaging.js b/messaging.js index 0d356256..5cd1e99e 100644 --- a/messaging.js +++ b/messaging.js @@ -14,7 +14,7 @@ function notifyAllTabs(request) { }); }); // 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); // notify self: the message no longer is sent to the origin in new Chrome if (typeof applyOnMessage !== 'undefined') { diff --git a/storage.js b/storage.js index 776c71d3..6a06bb7c 100644 --- a/storage.js +++ b/storage.js @@ -521,17 +521,6 @@ function deepMerge(target, obj1 /* plus any number of object arguments */) { 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) { if (!a || !b || typeof a != "object" || typeof b != "object") { return a === b;