Skip to content

Commit 507901c

Browse files
committed
More comprehensive AddToDom logic
I realized I hadn't looked closely enough at the AddToDom logic, and created an error if a canvas was passed to GameConfig without being added to the DOM first. This commit should fix that scenario and move the logic back into AddToDom() where it really belongs
1 parent d43bff0 commit 507901c

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/boot/Game.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,7 @@ var Game = new Class({
296296

297297
DebugHeader(this);
298298

299-
// If Phaser had to create its own canvas, add it to the DOM.
300-
if (!this.config.canvas)
301-
{
302-
AddToDOM(this.canvas, this.config.parent);
303-
}
299+
AddToDOM(this.canvas, this.config.parent);
304300

305301
this.events.emit('boot');
306302

src/dom/AddToDOM.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ var AddToDOM = function (element, parent, overflowHidden)
3636
target = parent;
3737
}
3838
}
39+
else if (element.parentElement)
40+
{
41+
return element;
42+
}
3943

4044
// Fallback, covers an invalid ID and a non HTMLelement object
4145
if (!target)

0 commit comments

Comments
 (0)