Skip to content

Commit

Permalink
Fix event listeners in dev mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mhochsteger committed Oct 15, 2024
1 parent ff94167 commit 120668f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions webgpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ async def main(canvas=None, shader_url="./shader.wgsl"):
if canvas is None:
canvas = document.getElementById("canvas")

# cloning and replacing the canvas removes all old event listeners
new_canvas = canvas.cloneNode(True)
canvas.parentNode.replaceChild(new_canvas, canvas)
canvas = new_canvas
del new_canvas

context = canvas.getContext("webgpu")
context.configure(
to_js(
Expand Down

0 comments on commit 120668f

Please sign in to comment.