Skip to content

Commit 56f801f

Browse files
committed
release prep
1 parent 2fc32b3 commit 56f801f

File tree

12 files changed

+96
-8
lines changed

12 files changed

+96
-8
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Changelog
22

33
## [2.0.3] - 2024-10-03
4+
* Added support for the experimental `moveBefore()` functionality in [Chrome Canary](https://www.google.com/chrome/canary/),
5+
see the [demo page](/examples/move-before) for more information.
6+
* Fixed `revealed` event when a resize reveals an element
7+
* Enabled `hx-preserve` in oob-swaps
8+
* Better degredation of `hx-boost` on forms with query parameters in their `action`
9+
* Improved shadowRoot support
10+
* Many smaller bug fixes
411

512
## [2.0.2] - 2024-08-12
613
* no longer boost forms of type `dialog`

dist/htmx.amd.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1465,7 +1465,7 @@ var htmx = (function() {
14651465
function restorePreservedElements() {
14661466
const pantry = find('#--htmx-preserve-pantry--')
14671467
if (pantry) {
1468-
for (const preservedElt of pantry.children) {
1468+
for (const preservedElt of [...pantry.children]) {
14691469
const existingElement = find('#' + preservedElt.id)
14701470
// @ts-ignore - use proposed moveBefore feature
14711471
existingElement.parentNode.moveBefore(preservedElt, existingElement)

dist/htmx.cjs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1464,7 +1464,7 @@ var htmx = (function() {
14641464
function restorePreservedElements() {
14651465
const pantry = find('#--htmx-preserve-pantry--')
14661466
if (pantry) {
1467-
for (const preservedElt of pantry.children) {
1467+
for (const preservedElt of [...pantry.children]) {
14681468
const existingElement = find('#' + preservedElt.id)
14691469
// @ts-ignore - use proposed moveBefore feature
14701470
existingElement.parentNode.moveBefore(preservedElt, existingElement)

dist/htmx.esm.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1464,7 +1464,7 @@ var htmx = (function() {
14641464
function restorePreservedElements() {
14651465
const pantry = find('#--htmx-preserve-pantry--')
14661466
if (pantry) {
1467-
for (const preservedElt of pantry.children) {
1467+
for (const preservedElt of [...pantry.children]) {
14681468
const existingElement = find('#' + preservedElt.id)
14691469
// @ts-ignore - use proposed moveBefore feature
14701470
existingElement.parentNode.moveBefore(preservedElt, existingElement)

dist/htmx.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1464,7 +1464,7 @@ var htmx = (function() {
14641464
function restorePreservedElements() {
14651465
const pantry = find('#--htmx-preserve-pantry--')
14661466
if (pantry) {
1467-
for (const preservedElt of pantry.children) {
1467+
for (const preservedElt of [...pantry.children]) {
14681468
const existingElement = find('#' + preservedElt.id)
14691469
// @ts-ignore - use proposed moveBefore feature
14701470
existingElement.parentNode.moveBefore(preservedElt, existingElement)

dist/htmx.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/htmx.min.js.gz

5 Bytes
Binary file not shown.

src/htmx.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1464,7 +1464,7 @@ var htmx = (function() {
14641464
function restorePreservedElements() {
14651465
const pantry = find('#--htmx-preserve-pantry--')
14661466
if (pantry) {
1467-
for (const preservedElt of pantry.children) {
1467+
for (const preservedElt of [...pantry.children]) {
14681468
const existingElement = find('#' + preservedElt.id)
14691469
// @ts-ignore - use proposed moveBefore feature
14701470
existingElement.parentNode.moveBefore(preservedElt, existingElement)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
+++
2+
title = "Experimental moveBefore() Support"
3+
insert_anchor_links = "left"
4+
+++
5+
6+
This page demonstrates the use of the experimental [`moveBefore()`](https://github.com/whatwg/dom/issues/1255) DOM
7+
API available in [Chrome Canary](https://www.google.com/chrome/canary/), which has been integrated into the `hx-preserve`
8+
attribute of htmx, if it is available.
9+
10+
### Getting Chrome Canary & Enabling `moveBefore()`
11+
12+
For the demo to work properly you will need to install Chrome Canary and enable the API:
13+
14+
* Navigate to <chrome://flags/#atomic-move>
15+
* Enable "Atomic DOM move"
16+
17+
htmx takes advantage of this API in the `hx-preserve` functionality if it is available, allowing you to mark an element
18+
as "preserved" and having all its state preserved as it moves between areas on the screen when new content is merged in.
19+
This is significantly better developer experience than current alternatives, such as morphing, which rely on the
20+
structure of the new page being "close enough" to not have to move things like video elements.
21+
22+
### Demo
23+
24+
If you inspect the video below you will see that it is embedded in a `div` element. If you click the "View Details"
25+
link, which is boosted, you will transition to another page with a video element with the same id, but embedded in
26+
a `figure` element instead. Without the `moveBefore()` functionality it is impossible to keep the video playing in
27+
this situation because "reparenting" (i.e. changing the parent of an element) causes it to reset.
28+
29+
`moveBefore()` opens up a huge number of possibilities in web development by allowing developers to completely change
30+
the layout of a page while still preserving elements play state, focus, etc.
31+
32+
<div class="center">
33+
<iframe hx-preserve="true" id="rick-roll" width="617" height="351" src="https://www.youtube.com/embed/GFq6wH5JR2A"
34+
title="Rick Astley - Never Gonna Give You Up (Official Music Video)" frameborder="0"
35+
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
36+
referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
37+
<div>
38+
<a hx-boost="true" href="/examples/move-before/details">View Details &rarr;</a>
39+
</div>
40+
</div>
41+
42+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
+++
2+
title = "Experimental moveBefore() Support"
3+
insert_anchor_links = "left"
4+
+++
5+
6+
### Demo
7+
8+
Note that the video kept playing, despite the fact it is now a child of a `figure` element. And you can click back
9+
and the video should continue to work as well. I enjoy flipping back and forth.
10+
11+
### Rick-Rolling
12+
13+
<figure>
14+
<iframe hx-preserve="true" id="rick-roll" width="617" height="351" src="https://www.youtube.com/embed/GFq6wH5JR2A"
15+
title="Rick Astley - Never Gonna Give You Up (Official Music Video)" frameborder="0"
16+
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
17+
referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
18+
<figcaption>A Classic Rick Roll</figcaption>
19+
</figure>
20+
21+
#### Background
22+
23+
Rickrolling or a Rickroll is an Internet meme involving the unexpected appearance of the music video to the 1987 hit
24+
song "Never Gonna Give You Up", performed by English singer Rick Astley. The aforementioned video has over 1.5 billion
25+
views on YouTube. The meme is a type of bait and switch, usually using a disguised hyperlink that leads to the music
26+
video. When one clicks on a seemingly unrelated link, the site with the music video loads instead of what was expected,
27+
and they have been "Rickrolled". The meme has also extended to using the song's lyrics, or singing it, in unexpected
28+
contexts. Astley himself has also been Rickrolled on several occasions.
29+
30+
The meme grew out of a similar bait-and-switch trick called "duck rolling" that was popular on the 4chan website in
31+
2006. The video bait-and-switch trick grew popular on 4chan by 2007 during April Fools' Day and spread to other Internet
32+
sites later that year. The meme gained mainstream attention in 2008 through several publicised events, particularly when
33+
YouTube used it on its 2008 April Fools' Day event.
34+
35+
Astley, who had only returned to performing after a 10-year hiatus, was initially hesitant about using his newfound
36+
popularity from the meme to further his career but accepted the fame by Rickrolling the 2008 Macy's Thanksgiving Day
37+
Parade with a surprise performance of the song. Since then, Astley has seen his performance career revitalized by the
38+
meme's popularity, and Rickrolling saw a massive resurgence online in the early 2020s.
39+

0 commit comments

Comments
 (0)