Skip to content

Conversation

@htcarr3
Copy link
Contributor

@htcarr3 htcarr3 commented Sep 30, 2025

@dvadell
Copy link

dvadell commented Oct 15, 2025

Hello everybody,

+1 for this please. We are seeing an exception when using turbo because of idiomorph's version. In this function from idiomorph 0.7.2:

function moveBeforeById(parentNode, id, after, ctx) {
      const target =
        /** @type {Element} - will always be found */
        (
          ctx.target.querySelector(#${id}) ||
            ctx.pantry.querySelector(#${id})
        );
      removeElementFromAncestorsIdMaps(target, ctx);
      moveBefore(parentNode, target, after);
      return target;
    }

Our id has square brackets, and querySelector needs the id escaped ( with backslashes or with CSS.escape() ).

In idiomorph's 0.7.4, they changed it to handle ids fine:

function moveBeforeById(parentNode, id, after, ctx) {
      const target =
        /** @type {Element} - will always be found */
        (     
          // ctx.target.id unsafe because of form input shadowing
          // ctx.target could be a document fragment which doesn't have getAttribute
          (ctx.target.getAttribute?.("id") === id && ctx.target) ||
            ctx.target.querySelector([id="${id}"]) ||
            ctx.pantry.querySelector([id="${id}"])
        );
      removeElementFromAncestorsIdMaps(target, ctx);
      moveBefore(parentNode, target, after);
      return target;
    }

Thanks

Copy link
Collaborator

@brunoprietog brunoprietog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @htcarr3!

@brunoprietog brunoprietog merged commit a1922ed into hotwired:main Oct 27, 2025
1 check passed
@htcarr3 htcarr3 deleted the bump_idiomorph_version_0_7_4 branch October 27, 2025 13:42
@htcarr3
Copy link
Contributor Author

htcarr3 commented Oct 27, 2025

@brunoprietog it looks like this is the only commit on main not already released. Thoughts on cutting a minor version release just for this?

@jorgemanrubia
Copy link
Member

Hey @htcarr3 I need to fix a regression we detected in a recent Turbo version. I will cut a release with that in place. Aiming to do it this week.

@htcarr3
Copy link
Contributor Author

htcarr3 commented Oct 27, 2025

@jorgemanrubia thank you!

@jorgemanrubia
Copy link
Member

New versions of turbo and turbo-rails released containing this one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants