implicitInheritance also inherits hx-get, hx-post and hx-trigger, which htmx 2 never inherited
With htmx.config.implicitInheritance = true, htmx 4 inherits hx-get, hx-post and the other verb attributes, and hx-trigger. htmx 2 never inherited these, so the flag does not restore htmx 2 behaviour. htmx-2-compat only sets this flag, so it has the same problem.
Verbs and triggers resolve through __attributeValue, which applies implicit inheritance to every attribute:
- src/htmx.js#L333 verb lookup, checked in the order get, post, put, and so on
- src/htmx.js#L725 trigger lookup
- src/htmx.js#L293 the inheritance selector
Reproduction
A panel loads a form that has its own hx-post:
<meta name="htmx-config" content='{"implicitInheritance": true}'>
<div id="panel" hx-get="/panel" hx-trigger="load"></div>
<!-- /panel returns: -->
<form hx-post="/save" hx-target="#out"><button>save</button></form><div id="out"></div>| Version | Page load | Click "save" |
|---|---|---|
| 2.0.10 | one GET /panel |
POST /save |
| 4.0.0 | GET /panel in an endless loop |
no POST; the browser submits the form natively |
The form inherits hx-get="/panel", which wins over its own hx-post because get is checked first. It also inherits hx-trigger="load", so every swap starts the next request.
Expected behaviour
Implicit inheritance applies only to the attributes htmx 2 inherited: hx-boost, hx-confirm, hx-disable (was hx-disabled-elt), hx-encoding, hx-headers, hx-include, hx-indicator, hx-push-url, hx-replace-url, hx-select, hx-select-oob, hx-swap, hx-sync, hx-target and hx-vals. Verbs, hx-action, hx-method and hx-trigger are never inherited.
Source: bigskysoftware/htmx