iterate style object props just once

This commit is contained in:
tophf 2021-12-23 05:09:23 +03:00
parent b88b71b9c7
commit e9ed8dc946

View File

@ -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();