diff --git a/README.md b/README.md index cb8d8bf..e9e1730 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ A core tenet of htmx is to inline implementation details, so that the behaviour 1. Include `booster.min.js` in the `
` of your page, right after `htmx`: ```html - + ``` 2. Create a folder in the webroot of your project to store your scripts, e.g. `/scripts/boosts/`. Add a `` tag and set the `basePath` of your folder: diff --git a/dist/booster-pack.min.mjs b/dist/booster-pack.min.mjs index 2d572e7..88995e6 100644 --- a/dist/booster-pack.min.mjs +++ b/dist/booster-pack.min.mjs @@ -93,7 +93,7 @@ class BoosterExt { next: {} }; function saveToCache(dom, store) { - let markers = dom.querySelectorAll("[data-" + extension + ']:not([data-reset="false"])'); + let markers = dom.querySelectorAll("[data-" + extension + '], [hx-history-preserve]:not([data-reset="false"])'); if (markers) for (let i = 0; i < markers.length; ++i) typeof markers[i].id < "u" && (cache[store][markers[i].id] = markers[i].outerHTML); diff --git a/dist/booster.min.js b/dist/booster.min.js index 3f584f7..5de74f1 100644 --- a/dist/booster.min.js +++ b/dist/booster.min.js @@ -8,7 +8,7 @@ class BoosterExt { next: {} }; function saveToCache(dom, store) { - let markers = dom.querySelectorAll("[data-" + extension + ']:not([data-reset="false"])'); + let markers = dom.querySelectorAll("[data-" + extension + '], [hx-history-preserve]:not([data-reset="false"])'); if (markers) for (let i = 0; i < markers.length; ++i) typeof markers[i].id < "u" && (cache[store][markers[i].id] = markers[i].outerHTML); diff --git a/lib/boosterExt.js b/lib/boosterExt.js index c9cae7d..1ee49ff 100644 --- a/lib/boosterExt.js +++ b/lib/boosterExt.js @@ -10,7 +10,8 @@ export default class BoosterExt { }; function saveToCache(dom, store) { - let markers = dom.querySelectorAll('[data-'+extension+']' + ':not([data-reset="false"])'); + // support [hx-history-preserve] as well as booster components + let markers = dom.querySelectorAll('[data-'+extension+'], [hx-history-preserve]' + ':not([data-reset="false"])'); if (markers) { for (let i = 0; i < markers.length; ++i) { if (typeof markers[i].id !== 'undefined') { diff --git a/package-lock.json b/package-lock.json index b700217..0b518cb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "htmx-booster-pack", - "version": "1.0.8", + "version": "1.0.9", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "htmx-booster-pack", - "version": "1.0.8", + "version": "1.0.9", "license": "BSD 2-Clause", "devDependencies": { "@rollup/plugin-inject": "^5.0.5", diff --git a/package.json b/package.json index c7e1116..6d8173f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "htmx-booster-pack", - "version": "1.0.8", + "version": "1.0.9", "description": "Minimal component framework for htmx", "type": "module", "exports": {