@@ -5,6 +5,7 @@ import type {
55 RuntimeResponse ,
66 RuntimeResult ,
77} from "./inspectionTypes" ;
8+ import { isElementNode } from "./domRealm" ;
89
910type Method = ( this : unknown , ...args : unknown [ ] ) => unknown ;
1011interface Animation {
@@ -91,7 +92,7 @@ export function installInspection(win: InspectorWindow, generation: string, limi
9192 function wrap ( owner : Record < string , unknown > , name : string , timeline : boolean ) {
9293 const original = owner [ name ] ;
9394 if ( typeof original !== "function" ) return ;
94- const method : Method = original ;
95+ const method = original as Method ;
9596 const wrapped : Method = function ( ...args ) {
9697 const outer = depth === 0 ;
9798 const stack = outer ? ( new Error ( ) . stack ?? "" ) : "" ;
@@ -181,7 +182,7 @@ export function installInspection(win: InspectorWindow, generation: string, limi
181182 elements = [
182183 ...new Set (
183184 roots . flatMap ( ( root ) => [
184- ...( root instanceof Element && root . matches ( selector ) ? [ root ] : [ ] ) ,
185+ ...( isElementNode ( root ) && root . matches ( selector ) ? [ root ] : [ ] ) ,
185186 ...root . querySelectorAll ( selector ) ,
186187 ] ) ,
187188 ) ,
@@ -197,7 +198,7 @@ export function installInspection(win: InspectorWindow, generation: string, limi
197198 candidates : elements . slice ( 0 , 20 ) . map ( describe ) ,
198199 truncated : elements . length > 20 ,
199200 } ;
200- const targetElement = elements [ 0 ] ;
201+ const targetElement = elements [ 0 ] ! ;
201202 const descendants = q . descendants ? [ ...targetElement . querySelectorAll ( "*" ) ] : [ ] ;
202203 const scope = [ targetElement , ...descendants . slice ( 0 , 1000 ) ] ;
203204 const animations = ( gsap ?. getTweensOf ?.( scope ) ?? [ ] ) . map ( ( tw ) : RuntimeAnimation => {
@@ -217,10 +218,7 @@ export function installInspection(win: InspectorWindow, generation: string, limi
217218 properties : Object . keys ( tw . vars ?? { } ) . filter (
218219 ( key ) => ! reserved . has ( key ) && ! key . startsWith ( "on" ) ,
219220 ) ,
220- targets : ( tw . targets ?.( ) ?? [ ] )
221- . filter ( ( el ) : el is Element => el instanceof Element )
222- . slice ( 0 , 50 )
223- . map ( describe ) ,
221+ targets : ( tw . targets ?.( ) ?? [ ] ) . filter ( isElementNode ) . slice ( 0 , 50 ) . map ( describe ) ,
224222 localStart : tw . startTime ( ) ,
225223 duration : tw . duration ( ) ,
226224 attachmentStacks,
0 commit comments