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

Add Type Safety Guards to turbo/fetch_requests #403

Merged
merged 2 commits into from
Nov 20, 2022

Commits on Nov 19, 2022

  1. Add Type Safety Guards to turbo/fetch_requests

    Without this change, GET `<form>` submissions without a Fetch Options `{
    body: }` raise the following:
    
    ```
    Uncaught TypeError: s.body is null
        <anonymous> fetch_requests.js:10
        w turbo.es2017-esm.js:351
        requestStarted turbo.es2017-esm.js:770
        perform turbo.es2017-esm.js:520
        start turbo.es2017-esm.js:744
        formSubmitted turbo.es2017-esm.js:3369
    ```
    
    Through the exercise of attempting to [port the `turbo/fetch_requests`
    module to
    TypeScript](hotwired#392 (comment)),
    we've identified some potential edge cases in the algorithm that
    determines a request's HTTP method.
    
    Even if the migration to TypeScript doesn't come to fruition for some
    time, those edge cases should be addressed sooner rather than later.
    
    This commit adds more "type safety" motivated conditionals and guards to
    make sure that values are present before overriding them.
    seanpdoyle committed Nov 19, 2022
    Configuration menu
    Copy the full SHA
    4868855 View commit details
    Browse the repository at this point in the history
  2. Resolve Turbo Stream test flakiness

    Replace looping mechanisms with Capybara assertion for the presence of a
    `<turbo-cable-stream-source>` element.
    seanpdoyle committed Nov 19, 2022
    Configuration menu
    Copy the full SHA
    2e38b70 View commit details
    Browse the repository at this point in the history