@@ -26,11 +26,10 @@ import { ChoreType } from '../shared/util-chore-type';
2626import { escapeHTML } from '../shared/utils/character-escaping' ;
2727import { _OWNER } from '../shared/utils/constants' ;
2828import {
29- getEventNameFromJsxEvent ,
29+ getEventDataFromHtmlAttribute ,
30+ getEventNameFromHtmlAttribute ,
3031 getEventNameScopeFromJsxEvent ,
3132 isHtmlAttributeAnEventName ,
32- isJsxPropertyAnEventName ,
33- jsxEventToHtmlAttribute ,
3433} from '../shared/utils/event-names' ;
3534import { getFileLocationFromJsx } from '../shared/utils/jsx-filename' ;
3635import {
@@ -604,23 +603,22 @@ export const vnode_diff = (
604603 // We never tell the vNode about them saving us time and memory.
605604 for ( const key in constProps ) {
606605 let value = constProps [ key ] ;
607- if ( isJsxPropertyAnEventName ( key ) ) {
608- // So for event handlers we must add them to the vNode so that qwikloader can look them up
609- // But we need to mark them so that they don't get pulled into the diff.
610- const eventName = getEventNameFromJsxEvent ( key ) ;
611- const scope = getEventNameScopeFromJsxEvent ( key ) ;
612- if ( eventName ) {
613- vNewNode ! . setProp ( HANDLER_PREFIX + ':' + scope + ':' + eventName , value ) ;
614- registerQwikLoaderEvent ( eventName ) ;
615- }
606+ if ( isHtmlAttributeAnEventName ( key ) ) {
607+ const data = getEventDataFromHtmlAttribute ( key ) ;
608+ if ( data ) {
609+ const scope = data [ 0 ] ;
610+ const eventName = data [ 1 ] ;
611+
612+ if ( eventName ) {
613+ vNewNode ! . setProp ( HANDLER_PREFIX + ':' + scope + ':' + eventName , value ) ;
614+ registerQwikLoaderEvent ( eventName ) ;
615+ }
616616
617- if ( scope ) {
618- // add an event attr with empty value for qwikloader element selector.
619- // We don't need value here. For ssr this value is a QRL,
620- // but for CSR value should be just empty
621- const htmlEvent = jsxEventToHtmlAttribute ( key ) ;
622- if ( htmlEvent ) {
623- vNewNode ! . setAttr ( htmlEvent , '' , journal ) ;
617+ if ( scope ) {
618+ // add an event attr with empty value for qwikloader element selector.
619+ // We don't need value here. For ssr this value is a QRL,
620+ // but for CSR value should be just empty
621+ vNewNode ! . setAttr ( key , '' , journal ) ;
624622 }
625623 }
626624
@@ -867,7 +865,7 @@ export const vnode_diff = (
867865 } ;
868866
869867 const recordJsxEvent = ( key : string , value : any ) => {
870- const eventName = getEventNameFromJsxEvent ( key ) ;
868+ const eventName = getEventNameFromHtmlAttribute ( key ) ;
871869 const scope = getEventNameScopeFromJsxEvent ( key ) ;
872870 if ( eventName ) {
873871 record ( ':' + scope + ':' + eventName , value ) ;
@@ -879,10 +877,7 @@ export const vnode_diff = (
879877 // add an event attr with empty value for qwikloader element selector.
880878 // We don't need value here. For ssr this value is a QRL,
881879 // but for CSR value should be just empty
882- const htmlEvent = jsxEventToHtmlAttribute ( key ) ;
883- if ( htmlEvent ) {
884- record ( htmlEvent , '' ) ;
885- }
880+ record ( key , '' ) ;
886881 }
887882 } ;
888883
@@ -910,7 +905,7 @@ export const vnode_diff = (
910905 } else if ( dstKey === undefined ) {
911906 // Destination exhausted: add remaining source keys
912907 const srcValue = srcAttrs [ srcIdx + 1 ] ;
913- if ( isJsxPropertyAnEventName ( srcKey ) ) {
908+ if ( isHtmlAttributeAnEventName ( srcKey ) ) {
914909 patchEventDispatch = true ;
915910 recordJsxEvent ( srcKey , srcValue ) ;
916911 } else {
@@ -932,7 +927,7 @@ export const vnode_diff = (
932927 } else if ( srcKey < dstKey ) {
933928 // Source has a key not in destination: add it
934929 const srcValue = srcAttrs [ srcIdx + 1 ] ;
935- if ( isJsxPropertyAnEventName ( srcKey ) ) {
930+ if ( isHtmlAttributeAnEventName ( srcKey ) ) {
936931 patchEventDispatch = true ;
937932 recordJsxEvent ( srcKey , srcValue ) ;
938933 } else {
0 commit comments