From e9ed8dc946a489a42a7b440e7a2ee5782364e793 Mon Sep 17 00:00:00 2001 From: tophf Date: Thu, 23 Dec 2021 05:09:23 +0300 Subject: [PATCH] iterate style object props just once --- manage/import-export.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/manage/import-export.js b/manage/import-export.js index 972b8a20..354283b9 100644 --- a/manage/import-export.js +++ b/manage/import-export.js @@ -341,15 +341,16 @@ async function exportToFile() { type, }).dispatchEvent(new MouseEvent('click')); /** strip `sections`, `null` and empty objects */ - function cleanupStyle(s) { - s = Object.assign({}, s); - if (s.usercssData) delete s.sections; - for (const [key, val] of Object.entries(s)) { - if (typeof val === 'object' && isEmptyObj(val)) { - delete s[key]; + function cleanupStyle(style) { + const copy = {}; + for (const [key, val] of Object.entries(style)) { + if (key === 'sections' + ? !style.usercssData + : typeof val !== 'object' || !isEmptyObj(val)) { + copy[key] = val; } } - return s; + return copy; } function generateFileName() { const today = new Date();