@@ -16,16 +16,19 @@ export class BlockScrollStrategy implements ScrollStrategy {
1616 private _previousHTMLStyles = { top : '' , left : '' } ;
1717 private _previousScrollPosition : { top : number , left : number } ;
1818 private _isEnabled = false ;
19+ private _document : Document ;
1920
20- constructor ( private _viewportRuler : ViewportRuler ) { }
21+ constructor ( private _viewportRuler : ViewportRuler , document : any ) {
22+ this . _document = document ;
23+ }
2124
2225 /** Attaches this scroll strategy to an overlay. */
2326 attach ( ) { }
2427
2528 /** Blocks page-level scroll while the attached overlay is open. */
2629 enable ( ) {
2730 if ( this . _canBeEnabled ( ) ) {
28- const root = document . documentElement ;
31+ const root = this . _document . documentElement ;
2932
3033 this . _previousScrollPosition = this . _viewportRuler . getViewportScrollPosition ( ) ;
3134
@@ -45,8 +48,8 @@ export class BlockScrollStrategy implements ScrollStrategy {
4548 /** Unblocks page-level scroll while the attached overlay is open. */
4649 disable ( ) {
4750 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 ;
5053 const previousHtmlScrollBehavior = html . style [ 'scrollBehavior' ] || '' ;
5154 const previousBodyScrollBehavior = body . style [ 'scrollBehavior' ] || '' ;
5255
@@ -71,11 +74,13 @@ export class BlockScrollStrategy implements ScrollStrategy {
7174 // Since the scroll strategies can't be singletons, we have to use a global CSS class
7275 // (`cdk-global-scrollblock`) to make sure that we don't try to disable global
7376 // 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 ) {
7580 return false ;
7681 }
7782
78- const body = document . body ;
83+ const body = this . _document . body ;
7984 const viewport = this . _viewportRuler . getViewportSize ( ) ;
8085 return body . scrollHeight > viewport . height || body . scrollWidth > viewport . width ;
8186 }
0 commit comments