diff options
author | Carson Gross <carson@bigsky.software> | 2024-07-12 11:12:56 -0600 |
---|---|---|
committer | Carson Gross <carson@bigsky.software> | 2024-07-12 11:12:56 -0600 |
commit | f751aba86fa449d9b3897d64ad489db47dc182a0 (patch) | |
tree | 7d74fb512f51c45ccdebf70f3f7b1979c1c396f2 | |
parent | ee13ae744a86b906d995402b3394aa7e5a324f02 (diff) | |
download | htmx-f751aba86fa449d9b3897d64ad489db47dc182a0.tar.gz htmx-f751aba86fa449d9b3897d64ad489db47dc182a0.zip |
remove only top level files to keep the legacy extensions
-rw-r--r-- | CHANGELOG.md | 6 | ||||
-rw-r--r-- | README.md | 2 | ||||
-rwxr-xr-x | scripts/dist.sh | 3 | ||||
-rw-r--r-- | src/htmx.js | 2 | ||||
-rw-r--r-- | www/content/_index.md | 2 | ||||
-rw-r--r-- | www/content/docs.md | 6 | ||||
-rw-r--r-- | www/static/src/htmx.d.ts | 2 | ||||
-rw-r--r-- | www/static/src/htmx.js | 9 | ||||
-rw-r--r-- | www/static/test/manual/index.html | 1 | ||||
-rw-r--r-- | www/themes/htmx-theme/static/js/htmx.js | 9 |
10 files changed, 28 insertions, 14 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index c76fd1e2..277903d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [2.0.1] - 2024-07-12 + +* Make the `/dist/htmx.esm.js` file the `main` file in `package.json` to make installing htmx smoother +* Update `htmx.d.ts` & include it in the distribution + + ## [2.0.0] - 2024-06-17 * Removed extensions and moved to their own repos linked off of <https://extensions.htmx.org> @@ -32,7 +32,7 @@ By removing these arbitrary constraints htmx completes HTML as a ## quick start ```html - <script src="https://unpkg.com/htmx.org@2.0.0"></script> + <script src="https://unpkg.com/htmx.org@2.0.1"></script> <!-- have a button POST a click via AJAX --> <button hx-post="/clicked" hx-swap="outerHTML"> Click Me diff --git a/scripts/dist.sh b/scripts/dist.sh index 87611fea..c64da0ad 100755 --- a/scripts/dist.sh +++ b/scripts/dist.sh @@ -5,7 +5,7 @@ set -euo pipefail HTMX_SRC="src/htmx.js" # Clean the dist directory -rm -rf dist/* +rm -rf dist/*.js dist/*.ts dist/*.gz # Regular IIFE script cp $HTMX_SRC dist/htmx.js @@ -35,3 +35,4 @@ cat > dist/htmx.esm.js << EOF $(cat $HTMX_SRC) export default htmx EOF + diff --git a/src/htmx.js b/src/htmx.js index eaec845d..834c6779 100644 --- a/src/htmx.js +++ b/src/htmx.js @@ -277,7 +277,7 @@ var htmx = (function() { parseInterval: null, /** @type {typeof internalEval} */ _: null, - version: '2.0.0' + version: '2.0.1' } // Tsc madness part 2 htmx.onLoad = onLoadHelper diff --git a/www/content/_index.md b/www/content/_index.md index 91b07dd6..c37ce351 100644 --- a/www/content/_index.md +++ b/www/content/_index.md @@ -119,7 +119,7 @@ By removing these constraints, htmx completes HTML as a [hypertext](https://en.w <h2>quick start</h2> ```html - <script src="https://unpkg.com/htmx.org@2.0.0"></script> + <script src="https://unpkg.com/htmx.org@2.0.1"></script> <!-- have a button POST a click via AJAX --> <button hx-post="/clicked" hx-swap="outerHTML"> Click Me diff --git a/www/content/docs.md b/www/content/docs.md index 814cacc5..8f2cb501 100644 --- a/www/content/docs.md +++ b/www/content/docs.md @@ -121,13 +121,13 @@ The fastest way to get going with htmx is to load it via a CDN. You can simply a your head tag and get going: ```html -<script src="https://unpkg.com/htmx.org@2.0.0" integrity="sha384-wS5l5IKJBvK6sPTKa2WZ1js3d947pvWXbPJ1OmWfEuxLgeHcEbjUUA5i9V5ZkpCw" crossorigin="anonymous"></script> +<script src="https://unpkg.com/htmx.org@2.0.1" integrity="sha384-Kuy3zzgrd0iLfD2M/Bid8+jwLls454XKE9xFQE7OPj4VIwd1vlTS/4oNMxjpTtOw" crossorigin="anonymous"></script> ``` An unminified version is also available for debugging as well: ```html -<script src="https://unpkg.com/htmx.org@2.0.0/dist/htmx.js" integrity="sha384-Xh+GLLi0SMFPwtHQjT72aPG19QvKB8grnyRbYBNIdHWc2NkCrz65jlU7YrzO6qRp" crossorigin="anonymous"></script> +<script src="https://unpkg.com/htmx.org@2.0.1/dist/htmx.js" integrity="sha384-ELJB0CrwJPIruxvwhqogOAeh84D/QrihzCpaCO63RB/OlBPyezKvFpceNNOra4PG" crossorigin="anonymous"></script> ``` While the CDN approach is extremely simple, you may want to consider @@ -149,7 +149,7 @@ and include it where necessary with a `<script>` tag: For npm-style build systems, you can install htmx via [npm](https://www.npmjs.com/): ```sh -npm install htmx.org +npm install htmx.org@2.0.1 ``` After installing, you’ll need to use appropriate tooling to use `node_modules/htmx.org/dist/htmx.js` (or `.min.js`). diff --git a/www/static/src/htmx.d.ts b/www/static/src/htmx.d.ts index 3775459f..2176ff4b 100644 --- a/www/static/src/htmx.d.ts +++ b/www/static/src/htmx.d.ts @@ -113,7 +113,7 @@ type HtmxAjaxHelperContext = { source?: Element | string; event?: Event; handler?: HtmxAjaxHandler; - target: Element | string; + target?: Element | string; swap?: HtmxSwapStyle; values?: any | FormData; headers?: Record<string, string>; diff --git a/www/static/src/htmx.js b/www/static/src/htmx.js index 1f0b622f..834c6779 100644 --- a/www/static/src/htmx.js +++ b/www/static/src/htmx.js @@ -277,7 +277,7 @@ var htmx = (function() { parseInterval: null, /** @type {typeof internalEval} */ _: null, - version: '2.0.0' + version: '2.0.1' } // Tsc madness part 2 htmx.onLoad = onLoadHelper @@ -1626,6 +1626,9 @@ var htmx = (function() { * @param {HtmxSettleInfo} settleInfo */ function swapOuterHTML(target, fragment, settleInfo) { + if (target instanceof Element && target.tagName === 'BODY') { // special case the body to innerHTML because DocumentFragments can't contain a body elt unfortunately + return swapInnerHTML(target, fragment, settleInfo) + } /** @type {Node} */ let newElt const eltBeforeNewContent = target.previousSibling @@ -1851,7 +1854,7 @@ var htmx = (function() { findAndSwapOobElements(fragment, settleInfo) forEach(findAll(fragment, 'template'), /** @param {HTMLTemplateElement} template */function(template) { findAndSwapOobElements(template.content, settleInfo) - if (template.content.childElementCount === 0) { + if (template.content.childElementCount === 0 && template.content.textContent.trim() === '') { // Avoid polluting the DOM with empty templates that were only used to encapsulate oob swap template.remove() } @@ -5033,7 +5036,7 @@ var htmx = (function() { * @property {Element|string} [source] * @property {Event} [event] * @property {HtmxAjaxHandler} [handler] - * @property {Element|string} target + * @property {Element|string} [target] * @property {HtmxSwapStyle} [swap] * @property {Object|FormData} [values] * @property {Record<string,string>} [headers] diff --git a/www/static/test/manual/index.html b/www/static/test/manual/index.html index 0c7d5c11..cda51718 100644 --- a/www/static/test/manual/index.html +++ b/www/static/test/manual/index.html @@ -17,6 +17,7 @@ <li><a href="poll-condition-test.html">Poll Conditionals</a></li> <li><a href="poll-clears-on-reinit-test.html">Polling Cancels On Reprocessing</a></li> <li><a href="cache-buster">Cache Busting Test</a></li> + <li><a href="body-swap">Body Swap Test</a></li> <li>Scroll Tests <ul> <li><a href="scroll-test-eventHandler.html">Scroll Event Handler</a></li> diff --git a/www/themes/htmx-theme/static/js/htmx.js b/www/themes/htmx-theme/static/js/htmx.js index 1f0b622f..834c6779 100644 --- a/www/themes/htmx-theme/static/js/htmx.js +++ b/www/themes/htmx-theme/static/js/htmx.js @@ -277,7 +277,7 @@ var htmx = (function() { parseInterval: null, /** @type {typeof internalEval} */ _: null, - version: '2.0.0' + version: '2.0.1' } // Tsc madness part 2 htmx.onLoad = onLoadHelper @@ -1626,6 +1626,9 @@ var htmx = (function() { * @param {HtmxSettleInfo} settleInfo */ function swapOuterHTML(target, fragment, settleInfo) { + if (target instanceof Element && target.tagName === 'BODY') { // special case the body to innerHTML because DocumentFragments can't contain a body elt unfortunately + return swapInnerHTML(target, fragment, settleInfo) + } /** @type {Node} */ let newElt const eltBeforeNewContent = target.previousSibling @@ -1851,7 +1854,7 @@ var htmx = (function() { findAndSwapOobElements(fragment, settleInfo) forEach(findAll(fragment, 'template'), /** @param {HTMLTemplateElement} template */function(template) { findAndSwapOobElements(template.content, settleInfo) - if (template.content.childElementCount === 0) { + if (template.content.childElementCount === 0 && template.content.textContent.trim() === '') { // Avoid polluting the DOM with empty templates that were only used to encapsulate oob swap template.remove() } @@ -5033,7 +5036,7 @@ var htmx = (function() { * @property {Element|string} [source] * @property {Event} [event] * @property {HtmxAjaxHandler} [handler] - * @property {Element|string} target + * @property {Element|string} [target] * @property {HtmxSwapStyle} [swap] * @property {Object|FormData} [values] * @property {Record<string,string>} [headers] |