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 1103 by evaluating hx-vals with this referring to the element #3139

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

maekoos
Copy link

@maekoos maekoos commented Jan 20, 2025

Description

Fixes #1103 by evaluating hx-vals attributes with this referring to the current element.

Example:

<div hx-post="/vars" hx-vals="javascript:{ ...this.dataset, }" data-name="a name" data-hello="world"></div>

evaluates to { "name": "a name", "hello": "world" } since this refers to the div with hx-vals attribute.

Corresponding issue: #1103

Testing

Added a test in test/attributes/hx-vals.js. This tests that this acually refers to the current element.

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

Edit: May also fix #1658

@Telroshan Telroshan added enhancement New feature or request ready for review Issues that are ready to be considered for merging labels Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request 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.

2 participants