|
1 | 1 | /** |
2 | 2 | * Router module for SPA navigation |
3 | 3 | */ |
4 | | -import { Router, transitions, renderer } from 'https://esm.sh/@profullstack/[email protected]'; |
| 4 | +import { Router, transitions, renderer, componentLoader } from 'https://esm.sh/@profullstack/[email protected]'; |
5 | 5 | import { localizer } from './i18n-setup.js'; |
6 | | -import { detectAndImportModules, executeInlineScripts, filterScriptTags } from './utils/component-loader.js'; |
7 | 6 | import { |
8 | 7 | initLoginPage, |
9 | 8 | initRegisterPage, |
@@ -42,13 +41,13 @@ async function loadPage(url) { |
42 | 41 | const doc = parser.parseFromString(html, 'text/html'); |
43 | 42 |
|
44 | 43 | // Import any modules |
45 | | - await detectAndImportModules(doc); |
| 44 | + await componentLoader.detectAndImportModules(doc); |
46 | 45 |
|
47 | 46 | // Execute any inline scripts |
48 | | - await executeInlineScripts(doc); |
| 47 | + await componentLoader.executeInlineScripts(doc); |
49 | 48 |
|
50 | | - // Filter out script tags |
51 | | - const contentWithoutScripts = filterScriptTags(doc.body); |
| 49 | + // Filter out script tags, but keep them for views |
| 50 | + const contentWithoutScripts = componentLoader.filterScriptTags(doc.body, true); // Keep script tags |
52 | 51 | const content = contentWithoutScripts.innerHTML; |
53 | 52 |
|
54 | 53 | // Pre-translate the content |
@@ -133,7 +132,8 @@ export function createRouter(options = {}) { |
133 | 132 | transition: customFade, |
134 | 133 | renderer: renderer.createRenderer({ |
135 | 134 | translateContainer: localizer.translateContainer.bind(localizer), |
136 | | - applyRTLToDocument: localizer.applyRTLToDocument.bind(localizer) |
| 135 | + applyRTLToDocument: localizer.applyRTLToDocument.bind(localizer), |
| 136 | + keepScripts: true // Keep script tags in views |
137 | 137 | }), |
138 | 138 | errorHandler: (path) => { |
139 | 139 | console.log('Custom error handler called for path:', path); |
|
0 commit comments