Skip to content

head extension fires duplicate event #4088

Description

@scrhartley

Note: This issue still exists after PR #4083.


Example below of head extension firing duplicate event.
The use of hx-preserve is just to make the script tags take a different path through the code, in order to better isolate this bug.

Output in console:

htmx:head:before:remove META
htmx:head:before:remove META

Page 1:

<!DOCTYPE html>
<html>
  <head>
    <script "hx-preserve" src="https://cdn.jsdelivr.net/npm/htmx.org@4.0.0/dist/htmx.js"></script>
    <script "hx-preserve" src="hx-head.js"></script>
    <meta name="description" content="An htmx page" />
  </head>
  <body hx-on="htmx:head:before:remove -> console.log(event.type, headElement.tagName)">
    <a href="page2.html" hx-boost="true">Go to page 2</a>
  </body>
</html>

Page 2:

<!DOCTYPE html>
<html>
  <head>
    <script "hx-preserve" src="https://cdn.jsdelivr.net/npm/htmx.org@4.0.0/dist/htmx.js"></script>
    <script "hx-preserve" src="hx-head.js"></script>
  </head>
  <body>This is page 2</body>
</html>

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions