Skip to content

Commit c209633

Browse files
Varixowmertens
authored andcommitted
fix: dispatch event on vnode
1 parent b6c0cf5 commit c209633

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

packages/qwik/src/core/client/vnode-diff.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ import { ChoreType } from '../shared/util-chore-type';
2626
import { escapeHTML } from '../shared/utils/character-escaping';
2727
import { _OWNER } from '../shared/utils/constants';
2828
import {
29+
fromCamelToKebabCase,
2930
getEventDataFromHtmlAttribute,
3031
isHtmlAttributeAnEventName,
3132
isJsxPropertyAnEventName,
32-
jsxEventToEventName,
3333
} from '../shared/utils/event-names';
3434
import { getFileLocationFromJsx } from '../shared/utils/jsx-filename';
3535
import {
@@ -765,7 +765,7 @@ export const vnode_diff = (
765765
// Event handler needs to be patched onto the element.
766766
if (!element.qDispatchEvent) {
767767
element.qDispatchEvent = (event: Event, scope: QwikLoaderEventScope) => {
768-
const eventName = jsxEventToEventName(event.type, 0, event.type.length);
768+
const eventName = fromCamelToKebabCase(event.type);
769769
const eventProp = ':' + scope.substring(1) + ':' + eventName;
770770
const qrls = [
771771
vNode.getProp<QRL>(eventProp, null),

packages/qwik/src/core/use/use-on.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@ import type {
88
} from '../shared/jsx/types/jsx-qwik-attributes';
99
import type { HostElement } from '../shared/types';
1010
import { USE_ON_LOCAL, USE_ON_LOCAL_FLAGS, USE_ON_LOCAL_SEQ_IDX } from '../shared/utils/markers';
11-
import {
12-
DOM_CONTENT_LOADED_EVENT,
13-
EventNameHtmlScope,
14-
createEventName,
15-
type EventNameJSXScope,
16-
} from '../shared/utils/event-names';
11+
import { EventNameHtmlScope, createEventName } from '../shared/utils/event-names';
1712

1813
export type EventQRL<T extends string = AllEventKeys> =
1914
| QRL<EventHandler<EventFromName<T>, Element>>

packages/qwik/src/testing/element-fixture.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ import type { ClientContainer } from '@qwik.dev/core/internal';
33
import { vi } from 'vitest';
44
import { assertDefined } from '../core/shared/error/assert';
55
import type { Container, QElement, QwikLoaderEventScope } from '../core/shared/types';
6-
import {
7-
EventNameHtmlScope,
8-
EventNameJSXScope,
9-
fromCamelToKebabCase,
10-
} from '../core/shared/utils/event-names';
6+
import { EventNameHtmlScope, fromCamelToKebabCase } from '../core/shared/utils/event-names';
117
import { QFuncsPrefix, QInstanceAttr } from '../core/shared/utils/markers';
128
import { delay } from '../core/shared/utils/promises';
139
import { invokeApply, newInvokeContextFromTuple } from '../core/use/use-core';
@@ -120,7 +116,11 @@ export async function trigger(
120116
cancelable: true,
121117
});
122118
Object.assign(event, eventPayload);
123-
const prefix = scope ? EventNameJSXScope.on + scope + ':' : EventNameHtmlScope.on;
119+
const prefix = scope
120+
? scope === '-document'
121+
? EventNameHtmlScope.document
122+
: EventNameHtmlScope.window
123+
: EventNameHtmlScope.on;
124124
const attrName = prefix + fromCamelToKebabCase(eventName);
125125
await dispatch(element, attrName, event, scope);
126126
}

0 commit comments

Comments
 (0)