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

Change reswap() type hint for method to str #422

Merged
merged 1 commit into from
Mar 1, 2024

Conversation

danjac
Copy link
Contributor

@danjac danjac commented Mar 1, 2024

Fix for #421

The HX-Swap directive and HX-Reswap response header allow modifiers in addition to the method, for example:

<div hx-swap="outerHTML show:window:top"><div>

This change allows any str value to be used for the method:

reswap(response, "outerHTML show:window:top")

Copy link
Owner

@adamchainz adamchainz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted on issue, let's just change the type hint to str, so we match the htmx syntax.

@danjac danjac changed the title Add "modifier" argument to reswap() Change "method" argument for reswap() to str Mar 1, 2024
@danjac
Copy link
Contributor Author

danjac commented Mar 1, 2024

Made suggested change and updated PR description.

Instead of using a Literal set of values, any string value can be used.
This allows modifiers e.g. "outerHTML show:window:top".
"delete",
"none",
],
method: str,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dropping trailing comma makes black format the function def on one line now

@adamchainz adamchainz changed the title Change "method" argument for reswap() to str Change reswap() type hint for method to str Mar 1, 2024
@adamchainz adamchainz merged commit 883d888 into adamchainz:main Mar 1, 2024
8 checks passed
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.

2 participants