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

Script tag: Uncaught TypeError: t is null #276

Closed
jes opened this issue Apr 28, 2024 · 2 comments · Fixed by #277
Closed

Script tag: Uncaught TypeError: t is null #276

jes opened this issue Apr 28, 2024 · 2 comments · Fixed by #277

Comments

@jes
Copy link
Contributor

jes commented Apr 28, 2024

I'm trying to use the Planck+Testbed example from https://piqnt.com/planck.js/docs/install :

<html><body>
  <script src="https://cdn.jsdelivr.net/npm/planck/dist/planck-with-testbed.min.js" />
  <script>
    const { World, Testbed } = planck;
    const world = new World();
 
    const testbed = Testbed.mount();
    testbed.start(world);
  </script>
</body></html>

This doesn't work because closing the script tag with .../> doesn't work. So I changed that to ...></script>, and then I get:

Uncaught TypeError: t is null
    mount StageTestbed.ts:42
    <anonymous> example.html:8
StageTestbed.ts:42:2

This is Firefox 116.0.2 on Linux.

@jes
Copy link
Contributor Author

jes commented Apr 28, 2024

OK, I've worked it out. The code in question is:

playButton.addEventListener('click', () => {
  mounted.isPaused() ? mounted.resume() : mounted.pause();
});

Preceded by:

// todo: should we create these elements if not exists?
const playButton = document.getElementById('testbed-play');

So, I guess yeah, maybe it should create these elements if not exists? Or perhaps console.log to tell people what to do. Or perhaps include them in the example HTML.

@jes
Copy link
Contributor Author

jes commented Apr 29, 2024

Closing issue, PR is approved.

@jes jes closed this as completed Apr 29, 2024
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 a pull request may close this issue.

1 participant