Skip to content

Commit 678ff95

Browse files
Replaced document by this.document manfredsteyer#773
Replaced document by this.document this uses the injected service instead of the native object.
1 parent ff82dd9 commit 678ff95

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

projects/lib/src/oauth-service.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -979,21 +979,21 @@ export class OAuthService extends AuthConfig implements OnDestroy {
979979
);
980980
}
981981

982-
if (typeof document === 'undefined') {
982+
if (typeof this.document === 'undefined') {
983983
throw new Error('silent refresh is not supported on this platform');
984984
}
985985

986-
const existingIframe = document.getElementById(
986+
const existingIframe = this.document.getElementById(
987987
this.silentRefreshIFrameName
988988
);
989989

990990
if (existingIframe) {
991-
document.body.removeChild(existingIframe);
991+
this.document.body.removeChild(existingIframe);
992992
}
993993

994994
this.silentRefreshSubject = claims['sub'];
995995

996-
const iframe = document.createElement('iframe');
996+
const iframe = this.document.createElement('iframe');
997997
iframe.id = this.silentRefreshIFrameName;
998998

999999
this.setupSilentRefreshEventListener();
@@ -1005,7 +1005,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
10051005
if (!this.silentRefreshShowIFrame) {
10061006
iframe.style['display'] = 'none';
10071007
}
1008-
document.body.appendChild(iframe);
1008+
this.document.body.appendChild(iframe);
10091009
});
10101010

10111011
const errors = this.events.pipe(
@@ -1177,7 +1177,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
11771177
);
11781178
return false;
11791179
}
1180-
if (typeof document === 'undefined') {
1180+
if (typeof this.document === 'undefined') {
11811181
return false;
11821182
}
11831183

@@ -1299,20 +1299,20 @@ export class OAuthService extends AuthConfig implements OnDestroy {
12991299
return;
13001300
}
13011301

1302-
const existingIframe = document.getElementById(this.sessionCheckIFrameName);
1302+
const existingIframe = this.document.getElementById(this.sessionCheckIFrameName);
13031303
if (existingIframe) {
1304-
document.body.removeChild(existingIframe);
1304+
this.document.body.removeChild(existingIframe);
13051305
}
13061306

1307-
const iframe = document.createElement('iframe');
1307+
const iframe = this.document.createElement('iframe');
13081308
iframe.id = this.sessionCheckIFrameName;
13091309

13101310
this.setupSessionCheckEventListener();
13111311

13121312
const url = this.sessionCheckIFrameUrl;
13131313
iframe.setAttribute('src', url);
13141314
iframe.style.display = 'none';
1315-
document.body.appendChild(iframe);
1315+
this.document.body.appendChild(iframe);
13161316

13171317
this.startSessionCheckTimer();
13181318
}
@@ -1335,7 +1335,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
13351335
}
13361336

13371337
public checkSession(): void {
1338-
const iframe: any = document.getElementById(this.sessionCheckIFrameName);
1338+
const iframe: any = this.document.getElementById(this.sessionCheckIFrameName);
13391339

13401340
if (!iframe) {
13411341
this.logger.warn(

0 commit comments

Comments
 (0)