I’m not sure if this is a bug or what, but there’s something unexpected going on.

I’ve set up a test for you to see here: https://perchance.org/sxvghvl53i#edit

I’ve got an $output that creates HTML, which contains the code [a.html], but escaped so that it’s not processed. So: \[a.html\].

This is then injected into the page, and actually processed correctly, replacing the contents with the a.html value. But then calling update() on that element either does nothing or throws an error of one kind or another.

It says that a_elem is undefined, when it should have already been injected into the page.

Honestly, I’ve been fiddling with this test for a while now and I can’t quite pin down exactly how it works or what this works and that doesn’t or what order things are being processed in… But some sort of shenanigans is going on.

If this is all working as expected, I’d love to learn how it works. But if not, consider this a bug report 😅

  • VioneTM
    link
    English
    13 months ago

    What I mean is after [a] has been called, the [a.add(...)] is called immediately after, without waiting for [a] to finish placing the element, in which the add(...) cannot call the a_elem since it hasn’t loaded yet.

    • @wthit56OP
      link
      English
      13 months ago

      Interesting… I don’t know why [a] would be async like that. Or if all [brackets] are processed later, processing them in order seems to be the easiest way anyway. Like… it’s not a big deal to put something in the DOM, it doesn’t need any delay, it can all be immediate.

      I think you’re right, that’s how it works, for whatever reason. This behaviour is just quite intuitive even for web devs like me–I’d avoid it at all costs in my own projects! 😂

      @perchance Any word on why it works like this, behind the scenes? I’m curious to understand it better.