Files
breadcrumb-the-shire/web/js/core/app-page-config.js
fs d9f07dcd63 fix: web/ quick wins — CSS cleanup, ARIA tabs, and file header comments
CSS:
- Remove duplicate li::before block in app-search.css
- Fix typo: search-reuslt → search-result in app-search.css
- Remove commented-out CSS rules in app-flash.css
- Add descriptive header comment to all 27 CSS component files

JS:
- Complete WAI-ARIA Tabs pattern: generate IDs, add aria-controls on
  tab buttons and aria-labelledby on tab panels (app-tabs.js)
- Add JSDoc header comments to ~33 JS files (core + components)
- Add explanatory block comment to app-boot.js (why classic IIFE)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 22:21:37 +01:00

41 lines
1.2 KiB
JavaScript

/**
* Reads JSON configuration embedded in the page via script#page-config-{id} elements.
*/
import { warnOnce } from './app-dom.js';
export function readPageConfig(configId, root = document) {
const id = `page-config-${String(configId || '').trim()}`;
if (!id || id === 'page-config-') {
warnOnce('UI_CONFIG_INVALID', 'Invalid page config id', { module: 'page-config', configId });
return null;
}
const node = root.getElementById(id);
if (!node) {
warnOnce('UI_CONFIG_MISSING', `Missing page config element: #${id}`, { module: 'page-config', configId });
return null;
}
const raw = String(node.textContent || '').trim();
if (raw === '') {
warnOnce('UI_CONFIG_EMPTY', `Empty page config payload: #${id}`, { module: 'page-config', configId });
return null;
}
try {
const parsed = JSON.parse(raw);
if (!parsed || typeof parsed !== 'object') {
warnOnce('UI_CONFIG_INVALID', `Page config is not an object: #${id}`, { module: 'page-config', configId });
return null;
}
return parsed;
} catch (error) {
warnOnce('UI_CONFIG_PARSE_FAIL', `Failed to parse page config: #${id}`, {
module: 'page-config',
configId,
error,
});
return null;
}
}