Skip to content

Commit 9692a6d

Browse files
wenhanchongchongw
andauthored
Fix for errors when using OFFSCREENCANVAS_SUPPORT (#25260)
This PR addresses an error encountered while using `OFFSCREENCANVAS_SUPPORT` for pthreads. Unable to find canvas in `findCanvasEventTarget` when canvas is `specialHTMLTargets`. ``` Uncaught TypeError: document.querySelector is not a function at findCanvasEventTarget at _wgpuInstanceCreateSurface ``` --------- Co-authored-by: chongw <[email protected]>
1 parent 9642ea3 commit 9692a6d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/lib/libhtml5.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ var LibraryHTML5 = {
346346
},
347347

348348
#if OFFSCREENCANVAS_SUPPORT
349-
$findCanvasEventTarget__deps: ['$GL', '$maybeCStringToJsString'],
349+
$findCanvasEventTarget__deps: ['$GL', '$maybeCStringToJsString', '$specialHTMLTargets'],
350350
$findCanvasEventTarget: (target) => {
351351
target = maybeCStringToJsString(target);
352352

@@ -365,6 +365,8 @@ var LibraryHTML5 = {
365365
// If not found, if one is querying by using DOM tag name selector 'canvas', grab the first
366366
// OffscreenCanvas that we can find.
367367
|| (target == 'canvas' && Object.keys(GL.offscreenCanvases)[0])
368+
// If not found, check specialHTMLTargets
369+
|| specialHTMLTargets[target]
368370
// If that is not found either, query via the regular DOM selector.
369371
#if PTHREADS
370372
|| (typeof document != 'undefined' && document.querySelector(target));

0 commit comments

Comments
 (0)