@@ -60,14 +60,18 @@ interface LegacyDomInsertionDispatcherState {
6060 version ?: unknown ;
6161}
6262
63+ function isNonNullObject ( value : unknown ) : value is Record < PropertyKey , unknown > {
64+ return typeof value === 'object' && value !== null ;
65+ }
66+
6367function isOptionalFunction (
6468 value : unknown
6569) : value is ( ( ...args : unknown [ ] ) => unknown ) | undefined {
6670 return value === undefined || typeof value === 'function' ;
6771}
6872
6973function isRegisteredDomInsertionHandler ( value : unknown ) : value is RegisteredDomInsertionHandler {
70- if ( typeof value !== 'object' || value === null ) {
74+ if ( ! isNonNullObject ( value ) ) {
7175 return false ;
7276 }
7377
@@ -81,7 +85,7 @@ function isRegisteredDomInsertionHandler(value: unknown): value is RegisteredDom
8185}
8286
8387function isDispatcherState ( value : unknown ) : value is DomInsertionDispatcherState {
84- if ( typeof value !== 'object' || value === null ) {
88+ if ( ! isNonNullObject ( value ) ) {
8589 return false ;
8690 }
8791
@@ -116,17 +120,11 @@ function compareHandlers(
116120}
117121
118122function getStateVersion ( state : unknown ) : unknown {
119- return typeof state === 'object' && state !== null
120- ? ( state as { version ?: unknown } ) . version
121- : undefined ;
123+ return isNonNullObject ( state ) ? state . version : undefined ;
122124}
123125
124126function restoreStaleDispatcherMethods ( existingState : unknown ) : void {
125- if (
126- typeof Element === 'undefined' ||
127- typeof existingState !== 'object' ||
128- existingState === null
129- ) {
127+ if ( typeof Element === 'undefined' || ! isNonNullObject ( existingState ) ) {
130128 return ;
131129 }
132130
0 commit comments