diff --git a/edit/edit.js b/edit/edit.js index 253d12ab..a5b144a4 100644 --- a/edit/edit.js +++ b/edit/edit.js @@ -325,14 +325,12 @@ function onRuntimeMessage(request) { request.reason !== 'editPreview' && request.reason !== 'editSave' && request.reason !== 'config') { - // code-less style from notifyAllTabs - const {sections, id} = request.style; - ((sections && sections[0] || {}).code === null - ? API.getStyle(id) - : Promise.resolve([request.style]) - ).then(([style]) => { - editor.replaceStyle(style, request.codeIsUpdated); - }); + Promise.resolve(request.codeIsUpdated === false ? + request.style : API.getStyle(request.style.id) + ) + .then(newStyle => { + editor.replaceStyle(newStyle, request.codeIsUpdated); + }); } break; case 'styleDeleted': diff --git a/edit/sections-editor.js b/edit/sections-editor.js index 0734221d..ec57d80f 100644 --- a/edit/sections-editor.js +++ b/edit/sections-editor.js @@ -942,7 +942,7 @@ function createSectionsEditor(style) { function replaceStyle(newStyle, codeIsUpdated) { // FIXME: avoid recreating all editors? reinit().then(() => { - style = newStyle; + Object.assign(style, newStyle); updateHeader(); dirty.clear(); // Go from new style URL to edit style URL diff --git a/edit/source-editor.js b/edit/source-editor.js index ce2f4fa1..4dd7331f 100644 --- a/edit/source-editor.js +++ b/edit/source-editor.js @@ -216,7 +216,7 @@ function createSourceEditor(style) { history.replaceState({}, '', `?id=${newStyle.id}`); } sessionStorage.justEditedStyleId = newStyle.id; - style = newStyle; + Object.assign(style, newStyle); $('#preview-label').classList.remove('hidden'); updateMeta(); livePreview.show(Boolean(style.id));