https://htmx.org logo
Join Discord
Powered by
# htmx-general
  • m

    mysterious-toddler-20573

    10/04/2020, 4:54 PM
    fml
  • m

    mysterious-toddler-20573

    10/04/2020, 4:54 PM
    OK
  • m

    mysterious-toddler-20573

    10/04/2020, 4:54 PM
    so, in fairness, you ARE sending two elements down, the button and then some content afterwards
  • m

    most-jelly-15242

    10/04/2020, 4:55 PM
    and can you identify this "some content" in the
    evt
    ?
  • m

    most-jelly-15242

    10/04/2020, 4:56 PM
    It's
    evt.target
    ?
  • m

    most-jelly-15242

    10/04/2020, 4:57 PM
    Then I guess using that as a check should be ok. But maybe also don't run the triggers if
    evt.target
    is null? Not sure if there's a use case for that.
  • g

    gorgeous-ghost-95789

    10/04/2020, 6:18 PM
    Even though it might deviate from the pure web standard, I think it’s completely reasonable to Trim() content before you swap it in.
  • g

    gorgeous-ghost-95789

    10/04/2020, 6:20 PM
    And, of you want to save on client side processing, it’s equally reasonable to just leave it, and say the HTML trays white space as a node, then call it a day.
  • m

    most-jelly-15242

    10/04/2020, 6:48 PM
    Now that i understand the root cause I can work around it with an if statement. It's a bit obscure and it may come up later on as an issue if others are using these events.
  • m

    mysterious-toddler-20573

    10/04/2020, 7:51 PM
    https://github.com/bigskysoftware/htmx/commit/e80169808cc4ee4a09783232d0b251ae0f206b22
  • m

    mysterious-toddler-20573

    10/04/2020, 7:51 PM
    @User ☝️ corrected w/ tests
  • m

    mysterious-toddler-20573

    10/04/2020, 7:52 PM
    problem is that when we swap outerHTML we need to trigger the event on all the new content, so we have to iterate through where the new content is triggering the event, and we weren't limiting that to only elements, so text nodes were getting triggered too
  • m

    mysterious-toddler-20573

    10/04/2020, 7:53 PM
    tests now ensure that we only trigger elements, not text nodes, and that if there are multiple top level new content nodes, both are triggered
  • m

    mysterious-toddler-20573

    10/04/2020, 7:53 PM
    swap outerHTML is hard :/
  • m

    most-jelly-15242

    10/04/2020, 9:23 PM
    @User Thanks for the changes. As I mentioned, this isn't an issue for me anymore, not only because I can test for it, but also because I no longer need to use the event after the addition of the after swap trigger response header. Having said that, the latest change doesn't prevent the duplicate swap from happening on my end. I am not sure why. I added a console.log within the while statement where you made the change:
    Copy code
    console.log(newElt, target, newElt.nodeType, Node.ELEMENT_NODE)
    And this is the output:
  • m

    most-jelly-15242

    10/04/2020, 9:24 PM
    newElt and target are different due to htmx classes. Not sure if that's expected. Then newElt.nodeType and Node.ELEMENT_NODe are both
    1
  • m

    most-jelly-15242

    10/04/2020, 9:25 PM
    On the afterSwap event I have another console.log
    Copy code
    console.log(name, evt.target);
    And this is the output:
  • m

    most-jelly-15242

    10/04/2020, 9:28 PM
    So I don't really understand why it's being triggered twice. I am using outerHTML as the default via htmx config because I am dynamically changing the hx-vars values in the outermost node so the updated values are then automatically included on the next update. This is for variables that are not inputs.
  • m

    mysterious-toddler-20573

    10/04/2020, 9:43 PM
    hmmm
  • m

    mysterious-toddler-20573

    10/04/2020, 9:44 PM
    i guess if you can use a codepen to reproduce?
  • m

    mysterious-toddler-20573

    10/04/2020, 9:44 PM
    I do ensure that we don't trigger the events for all content now w/ the outer swap, so at least that bug is fixed...
  • m

    mysterious-toddler-20573

    10/04/2020, 9:45 PM
    If you can boil it back down like the last one, that would be great
  • m

    mysterious-toddler-20573

    10/04/2020, 9:45 PM
    I'm sure it's something dumb
  • m

    most-jelly-15242

    10/04/2020, 10:14 PM
    I tried, but I can't replicate the issue on codepen 🤷‍♂️ https://codepen.io/jreviews/pen/dyMxrbd?editors=1011
  • m

    mysterious-toddler-20573

    10/04/2020, 10:15 PM
    OK, well, keep an eye out. If nothing else, you helped me improve htmx today
  • m

    most-jelly-15242

    10/04/2020, 10:16 PM
    I am very happy with the new header response options! Enjoy the rest of your Sunday!
  • m

    mysterious-toddler-20573

    10/05/2020, 12:27 AM
    @User I've checked in a first pass at event filtering here: https://github.com/bigskysoftware/htmx/commits/feature_event_filtering
  • m

    mysterious-toddler-20573

    10/05/2020, 12:27 AM
    still needs millions and millions of tests
  • m

    mysterious-toddler-20573

    10/05/2020, 12:27 AM
    but all the current tests pass
  • m

    mysterious-toddler-20573

    10/05/2020, 12:29 AM
    8.38kb to 8.86kb
1...515253...1146Latest