-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Hey, I've run into a few cases where I defined an hx-include on some parent elements, then wanted to expand those includes on a child element.
Consider the following example:
<input type="text" id="someInput" name="foo" value="bar">
<input type="text" id="anotherInput" name="name" value="whatever">
<div hx-include="#someInput">
<form hx-post="/test">
<input type="text" name="something" value="idk">
<button type="submit">Submit</button>
</form>
<form hx-post="/test2" hx-include="inherit, #anotherInput">
<input type="text" name="somethingElse" value="idk either">
<button type="submit">Submit</button>
</form>
</div>Until now, in those cases I've been simply duplicating the parent hx-include, so in this case I would write
<form hx-post="/test2" hx-include="#someInput, #anotherInput">Though you can imagine it gets quickly annoying if you had declared multiple values on the parent hx-include. And even more if you want multiple layers of hx-include to inherit
Hence this proposal: I feel it'd make sense to support a new inherit keyword, that could be specified in a comma-separated list selector, i.e. allow inherit along other specifiers, and allow syntax like
<div hx-include="#something, #somethingElse">
<div hx-include="inherit, input[name='whatever']">
<form hx-include="inherit, .selector">
...
</form>
</div>
</div>EDIT: looking at the code, the function findAttributeTargets is also used by hx-indicator, which would also benefit imo from this inherit list keyword