@@ -815,9 +815,10 @@ export class Replayer {
815
815
const { documentElement, head } = this . iframe . contentDocument ;
816
816
this . insertStyleRules ( documentElement , head ) ;
817
817
if ( ! this . service . state . matches ( 'playing' ) ) {
818
- this . iframe . contentDocument
819
- . getElementsByTagName ( 'html' ) [ 0 ]
820
- . classList . add ( 'rrweb-paused' ) ;
818
+ const iframeHtmlElement =
819
+ this . iframe . contentDocument . getElementsByTagName ( 'html' ) [ 0 ] ;
820
+
821
+ iframeHtmlElement && iframeHtmlElement . classList . add ( 'rrweb-paused' ) ;
821
822
}
822
823
this . emitter . emit ( ReplayerEvents . FullsnapshotRebuilded , event ) ;
823
824
if ( ! isSync ) {
@@ -1960,7 +1961,8 @@ export class Replayer {
1960
1961
styleSheet . rules ,
1961
1962
data . index ,
1962
1963
) as unknown as CSSStyleRule ;
1963
- rule . style &&
1964
+ rule &&
1965
+ rule . style &&
1964
1966
rule . style . setProperty (
1965
1967
data . set . property ,
1966
1968
data . set . value ,
@@ -1973,7 +1975,7 @@ export class Replayer {
1973
1975
styleSheet . rules ,
1974
1976
data . index ,
1975
1977
) as unknown as CSSStyleRule ;
1976
- rule . style && rule . style . removeProperty ( data . remove . property ) ;
1978
+ rule && rule . style && rule . style . removeProperty ( data . remove . property ) ;
1977
1979
}
1978
1980
}
1979
1981
@@ -2131,11 +2133,16 @@ export class Replayer {
2131
2133
}
2132
2134
2133
2135
private hoverElements ( el : Element ) {
2134
- ( this . lastHoveredRootNode || this . iframe . contentDocument )
2135
- ?. querySelectorAll ( '.\\:hover' )
2136
- . forEach ( ( hoveredEl ) => {
2136
+ const rootElement = this . lastHoveredRootNode || this . iframe . contentDocument ;
2137
+
2138
+ // Sometimes this throws because `querySelectorAll` is not a function,
2139
+ // unsure of value of rootElement when this occurs
2140
+ if ( rootElement && typeof rootElement . querySelectorAll === 'function' ) {
2141
+ rootElement . querySelectorAll ( '.\\:hover' ) . forEach ( ( hoveredEl ) => {
2137
2142
hoveredEl . classList . remove ( ':hover' ) ;
2138
2143
} ) ;
2144
+ }
2145
+
2139
2146
this . lastHoveredRootNode = el . getRootNode ( ) as Document | ShadowRoot ;
2140
2147
let currentEl : Element | null = el ;
2141
2148
while ( currentEl ) {
0 commit comments