Skip to content

Commit df4bb2a

Browse files
authored
[FIX] Allow Application#destroy to work under Node.js (playcanvas#3428)
1 parent c6afb57 commit df4bb2a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/framework/application.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1972,12 +1972,14 @@ class Application extends EventHandler {
19721972
var canvasId = this.graphicsDevice.canvas.id;
19731973

19741974
this.off('librariesloaded');
1975-
document.removeEventListener('visibilitychange', this._visibilityChangeHandler, false);
1976-
document.removeEventListener('mozvisibilitychange', this._visibilityChangeHandler, false);
1977-
document.removeEventListener('msvisibilitychange', this._visibilityChangeHandler, false);
1978-
document.removeEventListener('webkitvisibilitychange', this._visibilityChangeHandler, false);
1975+
1976+
if (typeof document !== 'undefined') {
1977+
document.removeEventListener('visibilitychange', this._visibilityChangeHandler, false);
1978+
document.removeEventListener('mozvisibilitychange', this._visibilityChangeHandler, false);
1979+
document.removeEventListener('msvisibilitychange', this._visibilityChangeHandler, false);
1980+
document.removeEventListener('webkitvisibilitychange', this._visibilityChangeHandler, false);
1981+
}
19791982
this._visibilityChangeHandler = null;
1980-
this.onVisibilityChange = null;
19811983

19821984
this.root.destroy();
19831985
this.root = null;

0 commit comments

Comments
 (0)