Giter Club home page Giter Club logo

Comments (2)

Renerick avatar Renerick commented on September 15, 2024

Do you by any chance use web components or some JS lib? I'm completely unable to reproduce Error: A callback for the method 'component-update'

As for subscription not working after first swap, this is a legitimate bug, but it doesn't seem to be related with the error message you observe

Disregard everything above. For some reason I did not see error message in the console so my initial analysis was completely wrong

from htmx-signalr.

Renerick avatar Renerick commented on September 15, 2024

Basically, the following happens

  1. Message is received
  2. Target is extracted from hx-target
  3. Swapping begins
  4. OOB swapping replaces the target
  5. The old target is unmounted from the DOM but the reference to it is still alive within the swapping method
  6. The normal swapping begins
  7. The element is unmounted so it has no siblings and no parent
  8. Error is raised

Workaround with innerHTML is working because there is no attempt to access parent or sibling of the target, and there is a lot of guards for empty values, so when it's unmounted from the DOM, no errors happen.

I'll have to do more triagin, for I suspect that this may affect any cases when OOB swap replaces original target. Maybe the issue would have to be moved back to htmx repo

As a general tip, I would advise against using OOB swaps on existing targets. OOB is intended to be used for updates somewhere else on the page, whereas in your case you are handling the same target. Simply returning [1] without hx-swap-oob from the hub works as expected

[1]

<div id="component" signalr-subscribe="echo" hx-target="this">Some new content here<div/>

from htmx-signalr.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.