Fix: replaceStyle make style name undefined
This commit is contained in:
parent
fa080d1913
commit
8016346035
12
edit/edit.js
12
edit/edit.js
|
@ -325,13 +325,11 @@ 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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue
Block a user