@@ -303,7 +303,8 @@ function closePalette() {
303303
304304/* ---- Delegated action click handler ---- */
305305function onActionClick ( e : Event ) {
306- const target = e . target as HTMLElement ;
306+ const target = e . target ;
307+ if ( ! ( target instanceof Element ) ) return ;
307308
308309 // Chrome delegations: palette-close, drawer open/close, explorer column toggles
309310 if ( target . closest ( '[data-palette-close]' ) ) { e . preventDefault ( ) ; closePalette ( ) ; return ; }
@@ -376,7 +377,8 @@ function wireOnce() {
376377
377378 // Delegated input: explorer search filter + palette input
378379 document . addEventListener ( 'input' , ( e ) => {
379- const target = e . target as HTMLElement ;
380+ const target = e . target ;
381+ if ( ! ( target instanceof Element ) ) return ;
380382 const searchInput = target . closest < HTMLInputElement > ( '[data-explorer-search]' ) ;
381383 if ( searchInput ) { filterExplorer ( searchInput ) ; return ; }
382384 const paletteInput = target . closest < HTMLInputElement > ( '[data-palette-input]' ) ;
@@ -386,7 +388,9 @@ function wireOnce() {
386388 // Delegated keydown: explorer search Enter-to-jump
387389 document . addEventListener ( 'keydown' , ( e ) => {
388390 if ( e . key !== 'Enter' ) return ;
389- const searchInput = ( e . target as HTMLElement ) . closest < HTMLInputElement > ( '[data-explorer-search]' ) ;
391+ const target = e . target ;
392+ if ( ! ( target instanceof Element ) ) return ;
393+ const searchInput = target . closest < HTMLInputElement > ( '[data-explorer-search]' ) ;
390394 if ( ! searchInput ) return ;
391395 const scope = searchInput . closest < HTMLElement > ( '[data-explorer-root]' ) ;
392396 if ( ! scope ) return ;
@@ -401,6 +405,7 @@ function wireOnce() {
401405}
402406
403407function onPage ( ) {
408+ document . querySelector ( '[data-studio]' ) ?. classList . add ( 'js' ) ;
404409 syncActive ( ) ;
405410}
406411
0 commit comments