-
Notifications
You must be signed in to change notification settings - Fork 435
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent form links from submitting multiple requests
The `LinkInterceptor` class contains some Frame-specific checks that were at the root of `<a data-turbo-method="...">` element clicks submitting multiple HTTP requests. To resolve the underlying issue, this commit changes the `FormLinkInterceptor` class to rely on an instance of `LinkClickObserver` instead of `LinkInterceptor`. In order to make that possible, this commit also extends the `LinkClickObserver` to accept a second argument to server as the [EventTarget][] for the `click` event listeners. As a consumer, the `FormLinkInterceptor` instances attached to `<turbo-frame>` element scope their listeners to the element, while the `Session`'s `FormLinkInterceptor` instance attaches a catch-all listener to the `window`. Since this commit changes the underlying event listening mechanism, it also renames the `FormLinkInterceptor` and delegate to `FormLinkClickObserver` to match the `LinkClickObserver` naming patterns. [EventTarget]: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget
- Loading branch information
1 parent
82937c6
commit afeb52d
Showing
5 changed files
with
86 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters