Skip to content

Commit e63b170

Browse files
feat: Patch events' naming for backward compatibility with older event namings
1 parent be86443 commit e63b170

File tree

1 file changed

+7
-0
lines changed
  • languages/javascript/src/shared/Events

1 file changed

+7
-0
lines changed

languages/javascript/src/shared/Events/index.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,13 @@ const doListen = function(module, event, callback, context, once, internal=false
127127
return Promise.reject('No valid module name provided')
128128
}
129129

130+
//TODO: This is a patch and should be removed! Adds "on" if the event does not start with "on".
131+
// Added temporarily for backward compatibility with older event namings
132+
if (event != '*' && !event.startsWith('on')) {
133+
event = 'on' + event[0].toUpperCase() + event.substring(1)
134+
console.warn(`Event names should begin with 'on'. Using '${module + '.' + event}' instead.`)
135+
}
136+
130137
const wildcard = event === '*'
131138
const events = (wildcard ? validEvents[module] : [event]) // explodes wildcards into an array
132139
const promises = []

0 commit comments

Comments
 (0)