Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | /** * Simple direct hydration for performance page buttons * This approach bypasses complex timing issues and directly attaches handlers */ console.log('🚀 Simple hydration starting...'); // Wait for both DOM and all scripts to be ready function waitForReady() { return new Promise(resolve => { if (document.readyState === 'complete') { resolve(); } else { window.addEventListener('load', resolve); } }); } // Wait a bit more for deferred scripts function waitForScripts() { return new Promise(resolve => setTimeout(resolve, 200)); } async function setupButtons() { try { await waitForReady(); await waitForScripts(); console.log('🔍 Checking for performance functions...'); console.log('window.runPerformanceTests:', typeof window.runPerformanceTests); console.log('window.runRenderingTest:', typeof window.runRenderingTest); console.log('window.runCacheTest:', typeof window.runCacheTest); console.log('window.clearResults:', typeof window.clearResults); // Direct button mapping const buttons = { 'run-all-tests': window.runPerformanceTests, 'run-render-test': window.runRenderingTest, 'run-cache-test': window.runCacheTest, 'clear-results': window.clearResults }; Object.entries(buttons).forEach(([buttonId, handler]) => { const button = document.getElementById(buttonId); if (button && handler) { console.log(`🎯 Setting up button: ${buttonId}`); // Remove any existing event listeners and data attributes button.removeAttribute('data-action'); button.removeAttribute('data-event'); button.removeAttribute('onclick'); // Clone and replace to remove all existing listeners const newButton = button.cloneNode(true); button.parentNode.replaceChild(newButton, button); // Add our handler newButton.addEventListener('click', (e) => { e.preventDefault(); e.stopImmediatePropagation(); console.log(`🎯 ${buttonId} clicked!`); try { handler(); } catch (error) { console.error(`Error executing ${buttonId}:`, error); } }); console.log(`✅ Button ${buttonId} connected successfully`); } else { console.warn(`⚠️ Button ${buttonId} or handler missing:`, { button: !!button, handler: typeof handler }); } }); console.log('🎉 Simple hydration complete!'); } catch (error) { console.error('❌ Hydration error:', error); } } // Start the setup setupButtons(); |