diff --git a/options/options.js b/options/options.js index b90b6cc..6c1b7d3 100644 --- a/options/options.js +++ b/options/options.js @@ -700,29 +700,47 @@ var ThemeOptions = function () { }); }; + // THEME HARDENING: run every startup step isolated — one throwing step must + // NEVER prevent bind() (without the save/change handlers, Save silently + // posts the stale options JSON; that is exactly the 2026-11-25 regression + // where JSON.parse($('#optionCssFiles').val()) threw on "inherit" at global + // level and nothing on the page saved anymore). + var safeStep = function (name, fn) { + try { + fn(); + } catch (e) { + if (window.console && console.ls && console.ls.error) { + console.ls.error('ThemeOptions step "' + name + '" failed: ' + (e && e.message ? e.message : e)); + } else if (window.console && console.error) { + console.error('ThemeOptions step "' + name + '" failed: ' + (e && e.message ? e.message : e)); + } + } + }; + var run = function () { - parseOptionObject(); + safeStep('parseOptionObject', parseOptionObject); - startupGeneralInherit(); + safeStep('startupGeneralInherit', startupGeneralInherit); - prepareSelectField(); - prepareTextField(); - parseParentSwitchFields(); - prepareCheckboxField(); - prepareFontField(); - prepareFruityThemeField(); - showInheritedValue(); + safeStep('prepareSelectField', prepareSelectField); + safeStep('prepareTextField', prepareTextField); + safeStep('parseParentSwitchFields', parseParentSwitchFields); + safeStep('prepareCheckboxField', prepareCheckboxField); + safeStep('prepareFontField', prepareFontField); + safeStep('prepareFruityThemeField', prepareFruityThemeField); + safeStep('showInheritedValue', showInheritedValue); // THEME ADDITION: font dropdown optgroup order (see above) - reorderFontDropdowns(); + safeStep('reorderFontDropdowns', reorderFontDropdowns); - bind(); + // ALWAYS bind, even if a prepare step above failed + safeStep('bind', bind); // set initial disabled status of child fields - updateAllChildren(); + safeStep('updateAllChildren', updateAllChildren); // THEME ADDITION: set initial visibility of conditional fields - updateVisibilityByParent(); + safeStep('updateVisibilityByParent', updateVisibilityByParent); }; return run; diff --git a/options/options.twig b/options/options.twig index 65ed7b6..dbaa6c7 100644 --- a/options/options.twig +++ b/options/options.twig @@ -43,7 +43,7 @@ heuristically cached copy (the file has only Last-Modified/ETag, no Cache-Control). Re-register it with a version token: bump OPTIONS_JS_TOKEN below whenever options/options.js changes, so every browser fetches the new file once. #} -{% set OPTIONS_JS_TOKEN = '20261125.4' %} +{% set OPTIONS_JS_TOKEN = '20261125.5' %} {{ unregisterScriptFile(optionsPath ~ '/options.js') }} {{ registerScriptFile(optionsPath ~ '/options.js?v=' ~ OPTIONS_JS_TOKEN, 'POS_END') }}