emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.92k stars 3.32k forks source link

Avoid try/catch in findEventTarget. NFC #22984

Closed sbc100 closed 1 week ago

sbc100 commented 1 week ago

Rather than using try/catch to detect when document is missing we explicitly check for it. This is the same pattern used in the other version of findEventTarget on line 336.

This avoids casting a wide net and hiding errors in the rest of the code in this function. Its also more consistent with the other version of findEventTarget.

sbc100 commented 1 week ago

I noticed this while reviewing https://github.com/emscripten-core/emscripten/pull/22959

sbc100 commented 1 week ago

lgtm but maybe the last paragraph in the PR description is worth a changelog entry?

I don't think it could have any material effect. findEventTarget should always be returning a DOM object.

sbc100 commented 1 week ago

lgtm but maybe the last paragraph in the PR description is worth a changelog entry?

I don't think it could have any material effect. findEventTarget should always be returning a DOM object.

I updated the change so there should be change at all there..