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

Projects
None yet
2 participants
@NQNStudios
Copy link
Contributor

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.

NQNStudios added some commits May 31, 2018

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
@photonstorm

This comment has been minimized.

Copy link
Owner

commented May 31, 2018

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

@NQNStudios

This comment has been minimized.

Copy link
Contributor Author

commented Jun 1, 2018

That's done. Thanks!

@photonstorm photonstorm merged commit d01758e into photonstorm:master Jun 3, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.