Skip to content

Commit

Permalink
Fix "Invalid value used as weak map key" error (T1186521) (#25491)
Browse files Browse the repository at this point in the history
  • Loading branch information
GoodDayForSurf authored Sep 5, 2023
1 parent 51eec6e commit a9c9448
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/devextreme/js/events/core/events_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import domAdapter from '../../core/dom_adapter';
import { getWindow, hasWindow } from '../../core/utils/window';
const window = getWindow();
import injector from '../../core/utils/dependency_injector';
import { isWindow, isFunction, isString } from '../../core/utils/type';
import { isWindow, isFunction, isString, isObject } from '../../core/utils/type';
import Callbacks from '../../core/utils/callbacks';
import errors from '../../core/errors';
import hookTouchProps from '../../events/core/hook_touch_props';
Expand Down Expand Up @@ -113,7 +113,8 @@ const eventsEngine = injector({
if(!noBubble) {
const parents = [];
const getParents = function(element) {
const parent = element.parentNode ?? element.host;
const parent = element.parentNode
?? (isObject(element.host) ? element.host : null);
if(parent) {
parents.push(parent);
getParents(parent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -639,3 +639,13 @@ QUnit.test('Hover events should be ignored if the target is a child of the curre

assert.ok(handlerSpy.notCalled);
});

QUnit.test('There is no exception if element "A" was clicked while element has no parent (T1186521)', function(assert) {
const el = document.createElement('a');

el.setAttribute('href', '#');

eventsEngine.trigger(el, 'click');

assert.ok(true, 'no exceptions were fired');
});

0 comments on commit a9c9448

Please sign in to comment.