@@ -16,16 +16,19 @@ export class BlockScrollStrategy implements ScrollStrategy {
16
16
private _previousHTMLStyles = { top : '' , left : '' } ;
17
17
private _previousScrollPosition : { top : number , left : number } ;
18
18
private _isEnabled = false ;
19
+ private _document : Document ;
19
20
20
- constructor ( private _viewportRuler : ViewportRuler ) { }
21
+ constructor ( private _viewportRuler : ViewportRuler , document : any ) {
22
+ this . _document = document ;
23
+ }
21
24
22
25
/** Attaches this scroll strategy to an overlay. */
23
26
attach ( ) { }
24
27
25
28
/** Blocks page-level scroll while the attached overlay is open. */
26
29
enable ( ) {
27
30
if ( this . _canBeEnabled ( ) ) {
28
- const root = document . documentElement ;
31
+ const root = this . _document . documentElement ;
29
32
30
33
this . _previousScrollPosition = this . _viewportRuler . getViewportScrollPosition ( ) ;
31
34
@@ -45,8 +48,8 @@ export class BlockScrollStrategy implements ScrollStrategy {
45
48
/** Unblocks page-level scroll while the attached overlay is open. */
46
49
disable ( ) {
47
50
if ( this . _isEnabled ) {
48
- const html = document . documentElement ;
49
- const body = document . body ;
51
+ const html = this . _document . documentElement ;
52
+ const body = this . _document . body ;
50
53
const previousHtmlScrollBehavior = html . style [ 'scrollBehavior' ] || '' ;
51
54
const previousBodyScrollBehavior = body . style [ 'scrollBehavior' ] || '' ;
52
55
@@ -71,11 +74,13 @@ export class BlockScrollStrategy implements ScrollStrategy {
71
74
// Since the scroll strategies can't be singletons, we have to use a global CSS class
72
75
// (`cdk-global-scrollblock`) to make sure that we don't try to disable global
73
76
// scrolling multiple times.
74
- if ( document . documentElement . classList . contains ( 'cdk-global-scrollblock' ) || this . _isEnabled ) {
77
+ const html = this . _document . documentElement ;
78
+
79
+ if ( html . classList . contains ( 'cdk-global-scrollblock' ) || this . _isEnabled ) {
75
80
return false ;
76
81
}
77
82
78
- const body = document . body ;
83
+ const body = this . _document . body ;
79
84
const viewport = this . _viewportRuler . getViewportSize ( ) ;
80
85
return body . scrollHeight > viewport . height || body . scrollWidth > viewport . width ;
81
86
}
0 commit comments