Skip to content

Commit

Permalink
check that document exists before mounting debug panel
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolodavis committed Mar 16, 2020
1 parent d84e6af commit aede3b6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,16 +279,19 @@ class _ClientImpl {
this.debug !== false &&
this._debugPanel == null
) {
let target = document.body;
if (this.debug && this.debug.target) {
let target = document && document.body;
if (this.debug && this.debug.target !== undefined) {
target = this.debug.target;
}
this._debugPanel = new debugImpl({
target,
props: {
client: this,
},
});

if (target) {
this._debugPanel = new debugImpl({
target,
props: {
client: this,
},
});
}
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/client/client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,13 @@ describe('start / stop', () => {
client.stop();
});

test('no error when mounting on null element', () => {
const client = Client({ game: {}, debug: { target: null } });
client.start();
client.stop();
expect(client._debugPanel).toBe(null);
});

test('override debug implementation', () => {
const client = Client({ game: {}, debug: { impl: Debug } });
client.start();
Expand Down

0 comments on commit aede3b6

Please sign in to comment.