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

Fix illegal invocation for FormData proxy #2997

Merged
merged 1 commit into from
Nov 7, 2024

Conversation

scrhartley
Copy link
Contributor

Description

Currently the form data proxy has special handing for if the return value is a function,
but not in the case where the key is a symbol. This omission can cause an error to be thrown.

Fixes constructor for URLSearchParams:

element.addEventListener('htmx:configRequest', function(event) {
    let params = new URLSearchParams(event.detail.parameters);
    console.log(params.toString());
});

If I was implementing this from fresh then I would use the more concise:

if (typeof result === 'function') {
    return result.bind(formData)
}

but instead I've replicated the existing approach:

if (typeof result === 'function') {
  return function() {
    return result.apply(formData, arguments)
  }
}

Corresponding issue: #2995

Testing

Added a new test to the existing ones for parameters.

Checklist

  • I have read the contribution guidelines
  • I have targeted this PR against the correct branch (master for website changes, dev for
    source changes)
  • This is either a bugfix, a documentation update, or a new feature that has been explicitly
    approved via an issue
  • I ran the test suite locally (npm run test) and verified that it succeeded

@Telroshan Telroshan added the bug Something isn't working label Nov 5, 2024
@Telroshan Telroshan added the ready for review Issues that are ready to be considered for merging label Nov 5, 2024
@1cg 1cg merged commit 6296912 into bigskysoftware:dev Nov 7, 2024
1 check passed
@1cg
Copy link
Contributor

1cg commented Nov 7, 2024

thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ready for review Issues that are ready to be considered for merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants