Skip to content

Commit

Permalink
Fix rare crash in event handler (#7525)
Browse files Browse the repository at this point in the history
* fix that addEventListenerWithDelegation could crash on non-Element event targets

* update changelog
  • Loading branch information
philippotto committed Jan 10, 2024
1 parent 883f955 commit b274c45
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
- Fixed a bug where meshes (or chunks of them) were always colored white, if they were loaded while the corresponding segmentation layer was disabled. [#7507](https://github.com/scalableminds/webknossos/pull/7507)
- Fixed a race condition when opening a short link, that would sometimes lead to an error toast. [#7507](https://github.com/scalableminds/webknossos/pull/7507)
- Fixed that the Segment Statistics feature was not available in the context menu of segment groups and in the context menu of the data viewports. [#7510](https://github.com/scalableminds/webknossos/pull/7510)
- Fixed rare bug which produced a benign error toast on some mouse interactions. [#7525](https://github.com/scalableminds/webknossos/pull/7525)
- Fixed a bug where dataset managers were not allowed to assign teams to new datasets that they are only member of. This already worked while editing the dataset later, but not during upload. [#7518](https://github.com/scalableminds/webknossos/pull/7518)
- Fixed regression in proofreading tool when automatic mesh loading was disabled and a merge/split operation was performed. [#7534](https://github.com/scalableminds/webknossos/pull/7534)
- Fixed that last dimension value in ND dataset was not loaded. [#7535](https://github.com/scalableminds/webknossos/pull/7535)
Expand Down
10 changes: 6 additions & 4 deletions frontend/javascripts/libs/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -765,10 +765,12 @@ export function addEventListenerWithDelegation(
handlerFunc: (...args: Array<any>) => any,
options: Record<string, any> = {},
) {
const wrapperFunc = function (event: Event) {
// @ts-ignore
for (let { target } = event; target && target !== this; target = target.parentNode) {
// @ts-ignore
const wrapperFunc = function (this: HTMLElement | Document, event: Event) {
for (
let { target } = event;
target && target !== this && target instanceof Element;
target = target.parentNode
) {
if (target.matches(delegateSelector)) {
handlerFunc.call(target, event);
break;
Expand Down

0 comments on commit b274c45

Please sign in to comment.