Skip to content

Extension Point: htmx.closestAttribute() #283

@benpate

Description

@benpate

htmx publishes closest() function, which is very helpful for making extensions. However, I'd really like to be able to use getClosestAttributeValue() to get a particular attribute as well. Is it possible to publish this on the "public" htmx API as well?

Alternatively, we might publish a "safe" attribute() function that could take a null value for the target node and not crash.

Use Case
I'm working on enhancements to the preload extension, and want to find the nearest instance of an attribute to configure its behavior. Since htmx already does this internally, it would be great to reuse this ability in an extension, too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions