@@ -6323,6 +6323,10 @@
var extraVars = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
+ if (modifiers.includes('camel')) {
+ event = camelCase(event);
+ }
+
if (modifiers.includes('away')) {
var _handler = function handler(e) {
_newArrowCheck(this, _this);
@@ -733,6 +733,10 @@
}
function registerListener(component, el, event, modifiers, expression, extraVars = {}) {
let handler = e => {
// Don't do anything if the click came form the element or within it.
@@ -1,6 +1,10 @@
-import { kebabCase, debounce, isNumeric } from '../utils'
+import { kebabCase, camelCase, debounce, isNumeric } from '../utils'
export function registerListener(component, el, event, modifiers, expression, extraVars = {}) {
@@ -463,3 +463,24 @@ test('autocomplete event does not trigger keydown with modifier callback', async
await wait(() => { expect(document.querySelector('span').innerText).toEqual(1) })
})
+test('.camel modifier correctly binds event listener', async () => {
+ document.body.innerHTML = `
+ <div x-data="{ foo: 'bar' }" x-on:event-name.camel.window="foo = 'bob'">
+ <button x-on:click="$dispatch('eventName')"></button>
+ <p x-text="foo"></p>
+ </div>
+ `
+ Alpine.start()
+ expect(document.querySelector('p').innerText).toEqual('bar')
+ document.querySelector('button').click();
+ await wait(() => {
+ expect(document.querySelector('p').innerText).toEqual('bob');
+ });
+})