bigskysoftware / bigskysoftware/htmx-extensions
loading-states.js `data-loading-states` scope not working properly
- Dominant language
- JavaScript
- Stars
- 284
- Forks
- 88
- PR merge metrics
- No merged PRs in 30d
Description
```html
// is boosted
request must not affect elements inside this div
// but it is, at the moment. All elements inside this div
// are affected by the outside GET request
...
```
The problem is in:
```js
function loadingStateContainer(target) {
return htmx.closest(target, "[data-loading-states]") || document.body;
}
function getLoadingStateElts(loadingScope, type, path) {
return Array.from(htmx.findAll(loadingScope, "[" + type + "]")).filter(
function (elt) {
return mayProcessLoadingStateByPath(elt, path);
},
);
}
```
The fix:
```js
function loadingStateContainer(target) {
return htmx.closest(target, "[data-loading-states]") || document.body;
}
function getLoadingStateElts(loadingScope, type, path) {
return Array.from(htmx.findAll(loadingScope, "[" + type + "]")).filter(
function (elt) {
return (
mayProcessLoadingStateByPath(elt, path) &&
// ensure that the loadingScope is the same as the specified scope
loadingStateContainer(elt) === loadingScope
);
},
);
}
```
Contributor guide
Assessment
This issue has not been assessed yet.