remove redundant app wrappers
This commit is contained in:
parent
d91611947e
commit
9e2076e80d
2 changed files with 32 additions and 29 deletions
|
|
@ -3,25 +3,25 @@
|
|||
// ============================================================
|
||||
|
||||
// ── Client-side error logging ──────────────────────────────
|
||||
(function() {
|
||||
function sendError(data) {
|
||||
try {
|
||||
navigator.sendBeacon('/api/logs/client-error', new Blob(
|
||||
[JSON.stringify(data)], { type: 'application/json' }
|
||||
));
|
||||
} catch(e) {}
|
||||
}
|
||||
window.onerror = function(msg, src, line, col, err) {
|
||||
// Ignore errors from browser extensions
|
||||
if (src && src.indexOf('moz-extension') !== -1) return;
|
||||
if (src && src.indexOf('chrome-extension') !== -1) return;
|
||||
sendError({ type: 'uncaught', message: String(msg), source: src, line: line, col: col, stack: err && err.stack });
|
||||
};
|
||||
window.addEventListener('unhandledrejection', function(e) {
|
||||
var msg = e.reason ? (e.reason.message || String(e.reason)) : 'Unhandled promise rejection';
|
||||
sendError({ type: 'unhandledrejection', message: msg, stack: e.reason && e.reason.stack });
|
||||
});
|
||||
})();
|
||||
function sendError(data) {
|
||||
try {
|
||||
navigator.sendBeacon('/api/logs/client-error', new Blob(
|
||||
[JSON.stringify(data)], { type: 'application/json' }
|
||||
));
|
||||
} catch(e) {}
|
||||
}
|
||||
|
||||
window.onerror = function(msg, src, line, col, err) {
|
||||
// Ignore errors from browser extensions
|
||||
if (src && src.indexOf('moz-extension') !== -1) return;
|
||||
if (src && src.indexOf('chrome-extension') !== -1) return;
|
||||
sendError({ type: 'uncaught', message: String(msg), source: src, line: line, col: col, stack: err && err.stack });
|
||||
};
|
||||
|
||||
window.addEventListener('unhandledrejection', function(e) {
|
||||
var msg = e.reason ? (e.reason.message || String(e.reason)) : 'Unhandled promise rejection';
|
||||
sendError({ type: 'unhandledrejection', message: msg, stack: e.reason && e.reason.stack });
|
||||
});
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
|
|
@ -410,15 +410,13 @@ function loadAnnouncement() {
|
|||
}
|
||||
|
||||
// Close button — dismiss for this page view only (reappears on refresh/re-login)
|
||||
(function() {
|
||||
var closeBtn = document.getElementById('announcement-close');
|
||||
if (closeBtn) {
|
||||
closeBtn.addEventListener('click', function() {
|
||||
var banner = document.getElementById('announcement-banner');
|
||||
if (banner) banner.classList.add('hidden');
|
||||
});
|
||||
}
|
||||
})();
|
||||
var closeBtn = document.getElementById('announcement-close');
|
||||
if (closeBtn) {
|
||||
closeBtn.addEventListener('click', function() {
|
||||
var banner = document.getElementById('announcement-banner');
|
||||
if (banner) banner.classList.add('hidden');
|
||||
});
|
||||
}
|
||||
|
||||
function getSelectedModel() {
|
||||
// Prefer the active tab's own model selector if present
|
||||
|
|
|
|||
|
|
@ -11,6 +11,11 @@ const moduleEntrypoints = [
|
|||
'public/js/wellVisit.js'
|
||||
];
|
||||
|
||||
const iifeFreeEntrypoints = [
|
||||
...moduleEntrypoints,
|
||||
'public/js/app.js'
|
||||
];
|
||||
|
||||
function readProjectFile(relativePath) {
|
||||
return fs.readFileSync(path.join(__dirname, '..', relativePath), 'utf8');
|
||||
}
|
||||
|
|
@ -25,7 +30,7 @@ test('refactored frontend entrypoints are loaded as modules', () => {
|
|||
});
|
||||
|
||||
test('refactored module entrypoints do not use redundant IIFE wrappers', () => {
|
||||
moduleEntrypoints.forEach((entrypoint) => {
|
||||
iifeFreeEntrypoints.forEach((entrypoint) => {
|
||||
const source = readProjectFile(entrypoint);
|
||||
assert.doesNotMatch(source, /^\s*\(function\s*\(/m, `${entrypoint} should not open an IIFE wrapper`);
|
||||
assert.doesNotMatch(source, /^\s*\}\)\(\);\s*$/m, `${entrypoint} should not close an IIFE wrapper`);
|
||||
|
|
|
|||
Loading…
Reference in a new issue