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

    quick-father-45112

    11/07/2022, 3:36 AM
    Same error in Chrome
  • q

    quick-father-45112

    11/07/2022, 3:36 AM
    Copy code
    ncaught DOMException: Failed to execute 'querySelectorAll' on 'Document': '#1_1_18' is not a valid selector.
        at I (https://unpkg.com/htmx.org@1.8.2:1:5813)
        at Q (https://unpkg.com/htmx.org@1.8.2:1:6204)
        at re (https://unpkg.com/htmx.org@1.8.2:1:7030)
        at lr (https://unpkg.com/htmx.org@1.8.2:1:31359)
        at https://unpkg.com/htmx.org@1.8.2:1:19749
        at HTMLButtonElement.i (https://unpkg.com/htmx.org@1.8.2:1:16275)
  • m

    mysterious-toddler-20573

    11/07/2022, 3:38 AM
    interesting
  • m

    mysterious-toddler-20573

    11/07/2022, 3:38 AM
    it looks like ids need to start w/ an alpha
  • m

    mysterious-toddler-20573

    11/07/2022, 3:39 AM
    i didn't know that
  • q

    quick-father-45112

    11/07/2022, 3:39 AM
    not for other use... works fine everywhere else I'm using it like this.
  • m

    mysterious-toddler-20573

    11/07/2022, 3:39 AM
    if you run it through
    querySelectorAll
    it doesn't like that
  • q

    quick-father-45112

    11/07/2022, 3:40 AM
    well, it may "officially" need start start with an alpha, but seems to work with HTML and general JS without issue.
  • m

    mysterious-toddler-20573

    11/07/2022, 3:40 AM
    https://www.w3.org/TR/html4/types.html#type-id
  • q

    quick-father-45112

    11/07/2022, 3:40 AM
    Ok, I can work with this limitation by re-working how I encode my div names
  • m

    mysterious-toddler-20573

    11/07/2022, 3:41 AM
    any javascript that invokes
    querySelectorAll()
    is gonna break w/ those ids
  • m

    mysterious-toddler-20573

    11/07/2022, 3:41 AM
    apparently
  • m

    mysterious-toddler-20573

    11/07/2022, 3:41 AM
    > ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
  • q

    quick-father-45112

    11/07/2022, 3:41 AM
    Yup, understood. But
    hx-target
    is working for other stuff like swapping HTML etc... so wojuldn't that also use the same
    querySelectorAll()
    ?
  • m

    mysterious-toddler-20573

    11/07/2022, 3:42 AM
    querySelectorAll()
    is a core DOM API: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll
  • m

    mysterious-toddler-20573

    11/07/2022, 3:42 AM
    that hx-target calls out to, so it isn't htmx that is causing this, it's the underlying DOM API that doesn't like that ID
  • q

    quick-father-45112

    11/07/2022, 3:43 AM
    I'm aware of that... not blaming htmx... I'm using that ID naming on hundreds of elements, it all over with all sorts of htmx calls, it's only the
    hx-confirm
    that is failing.
  • m

    mysterious-toddler-20573

    11/07/2022, 3:43 AM
    https://codepen.io/pen/?editors=1111
  • m

    mysterious-toddler-20573

    11/07/2022, 3:43 AM
    I can replicate it failing w/o an
    hx-confirm
  • m

    mysterious-toddler-20573

    11/07/2022, 3:44 AM
    https://codepen.io/1cg/pen/NWzREvb?editors=1111
  • m

    mysterious-toddler-20573

    11/07/2022, 3:44 AM
    if it's working sometimes... i dunno man, seems like it shouldn't work at all
  • q

    quick-father-45112

    11/07/2022, 3:45 AM
    Yup, all good... not trying to point fingers!! 🙂 Will redo my ID naming system to ensure an alpha at the start of the string.
  • q

    quick-father-45112

    11/07/2022, 3:46 AM
    Is there a way to have htmx throw a more understandable error if this happens in the future?
  • m

    mysterious-toddler-20573

    11/07/2022, 3:46 AM
    this is where we call out to it in our finding logic (after some stuff to support relative targets): https://github.com/bigskysoftware/htmx/blob/822132d6a24d320aebc1ebcf85f721c3fc188218/src/htmx.js#L535
  • m

    mysterious-toddler-20573

    11/07/2022, 3:47 AM
    I can look at it. The browsers (especially Safari) often report pretty terrible error messages unfortunately.
  • q

    quick-father-45112

    11/07/2022, 3:48 AM
    Yeah, I don't think I'd ever have worked out the issue from the error in Safari, though it makes perfect sense now 🙂
  • m

    mysterious-toddler-20573

    11/07/2022, 3:48 AM
    the new IE
  • m

    mysterious-toddler-20573

    11/07/2022, 3:48 AM
    OK, gotta bounce, sorry for the trouble
  • q

    quick-father-45112

    11/07/2022, 3:48 AM
    All good, thanks for popping it to look into it! Much appreciated 🙂
  • c

    creamy-dawn-16627

    11/07/2022, 6:59 AM
    can I do something like hx-target="find .comment_list" . I have a list and a comment form under, I've put the hx-target on the tag element wrapping both, and it's not working.
1...894895896...1146Latest