Becavalier / Becavalier/Book-DISO-WebAssembly
第七章7.3.4 touch事件Demo和7.4.2事件Demo无法运行
- Dominant language
- WebAssembly
- Stars
- 72
- Forks
- 16
- PR merge metrics
- No merged PRs in 30d
Description
emcc版本号:(emscripten 1.38.30 : 1.38.30)
错误:
使用书上提示命令
```shell
# 7.3.4
emcc html5_touch.cc --bind -s WASM=1 -o html5_touch.html
# 7.4.2
emcc sdl.cc -s WASM=1 -s FORCE_FILESYSTEM=1 -s USE_SDL=2 --preload-file hello_sdl.bmp -o sdl.html
```
行html时提示如下错误,
> sdl.html:1246 Rules for selecting event targets in HTML5 API are changing: instead of using document.getElementById() that only can refer to elements by their DOM ID, new event target selection mechanism uses the more flexible function document.querySelector() that can look up element names, classes, and complex CSS selectors. Build with -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 to change to the new lookup rules. See https://github.com/emscripten-core/emscripten/pull/7977 for more details.
在https://github.com/emscripten-core/emscripten/pull/7977 查看需要添加`-s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1`参数,添加后,会报\
>sdl.html:1246 exception thrown: SyntaxError: Failed to execute 'querySelector' on 'Document': The provided selector is empty.,Error: Failed to execute 'querySelector' on 'Document': The provided selector is empty.
at __findEventTarget (http://localhost:8081/sdl/sdl.js:6853:101)
at __findCanvasEventTarget (http://localhost:8081/sdl/sdl.js:6859:56)
at _emscripten_set_canvas_element_size (http://localhost:8081/sdl/sdl.js:6879:20)
at wasm-function[738]:271
at wasm-function[1025]:3063
at wasm-function[280]:128
at wasm-function[283]:49
at Object.Module._main (http://localhost:8081/sdl/sdl.js:9790:33)
at Object.callMain (http://localhost:8081/sdl/sdl.js:10086:30)
at doRun (http://localhost:8081/sdl/sdl.js:10144:60)
printErr @ sdl.html:1246
callMain @ sdl.js:10106
doRun @ sdl.js:10144
(anonymous) @ sdl.js:10155
setTimeout (async)
run @ sdl.js:10151
runCaller @ sdl.js:10063
removeRunDependency @ sdl.js:1694
receiveInstance @ sdl.js:1788
receiveInstantiatedSource @ sdl.js:1815
Promise.then (async)
createWasm @ sdl.js:1831
Module.asm @ sdl.js:1864
(anonymous) @ sdl.js:9661
17:11:54.241 sdl.js:218 Uncaught DOMException: Failed to execute 'querySelector' on 'Document': The provided selector is empty.
at __findEventTarget (http://localhost:8081/sdl/sdl.js:6853:101)
at __findCanvasEventTarget (http://localhost:8081/sdl/sdl.js:6859:56)
at _emscripten_set_canvas_element_size (http://localhost:8081/sdl/sdl.js:6879:20)
at wasm-function[738]:271
at wasm-function[1025]:3063
at wasm-function[280]:128
at wasm-function[283]:49
at Object.Module._main (http://localhost:8081/sdl/sdl.js:9790:33)
at Object.callMain (http://localhost:8081/sdl/sdl.js:10086:30)
at doRun (http://localhost:8081/sdl/sdl.js:10144:60)
暂时没找到可解决的方案
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the commands for html5_touch.cc and sdl.cc with emscripten 1.38.30, then inspect the generated sdl.html and sdl.js around the reported event-target error. Compare the behavior with and without DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR; done means both chapter demos run without the reported browser exceptions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, wasm
- Domain
- tooling, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100