Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't re-add a user-specified Canvas to DOM #3723

Merged
merged 4 commits into from Jun 3, 2018

Conversation

NQNStudios
Copy link
Contributor

@NQNStudios NQNStudios commented May 31, 2018

This PR fixes a bug.

Changes

While it was possible to pass an existing canvas element into the Game constructor, the AddToDom() method was moving the element onto document.body regardless of whether it already had a parent. This was causing my canvas to be repositioned unexpectedly, defeating the purpose of passing my own in (custom positioning of the canvas among other HTML elements).

Now, if GameConfig.parent is undefined but the canvas already has one, it won't be moved.

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
@photonstorm
Copy link
Collaborator

Happy to merge this, but please remove your changes to gitignore and package-lock first, thanks.

@NQNStudios
Copy link
Contributor Author

That's done. Thanks!

@photonstorm photonstorm merged commit d01758e into phaserjs:master Jun 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants