Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't register listener for custom directive #8259

Merged
merged 2 commits into from
Apr 4, 2024

Conversation

calebporzio
Copy link
Collaborator

Livewire supports "wildcard" event listeners like this:

<div wire:some-event="someMethod">...</div>

If what comes after wire: isn't a built-in directive, Livewire will register an event listener for it and fire the method when the event is fired. (This is actually how wire:click itself works - it's just a wildcard event)

However, if you register a custom directive like this:

Livewire.directive('sort', ({ ... }) => { ... })

Livewire will encounter <div wire:sort and not only run your custom directive code, but also register a listener for the sort event.

This PR disables that behavior so that errant custom directive names don't cause odd behavior with native events.

@calebporzio calebporzio marked this pull request as ready for review April 4, 2024 20:48
@calebporzio calebporzio merged commit 5dd96cf into main Apr 4, 2024
15 checks passed
@joshhanley joshhanley deleted the dont-register-listener-for-custom-directive branch April 18, 2024 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant