_hyperscript
_hyperscript copied to clipboard
Cannot append to html element
Hej, love the code, amazing work!
Now, to the issues - I am trying to append some text to a html element, below is POC code:
<div _="on click append 'foo' to #bottom">Click</div><div id="bottom">Hello</div>
The script fails with undefined undefined
error from line 1771 in the hyperscript.js file.
Looking deeper the error is actually: Unable to append to idRef
from the parser.addCommand
function.
Alternatively, the following code does not throw errors (although it does not achieve the same result):
<div _="on click append 'foo' put it into #bottom">click</div><div id="bottom">Hello</div>
At this point I do not know enought about the inner working of hyperscript hence the issue ...
Looks to me like you want something like this:
<div _="on click put 'foo' at end of #bottom">click</div><div id="bottom">Hello</div>
https://hyperscript.org/commands/put/
Yes - @1cg 's suggestion is a good workaround, but "append" should work this way. I'm sorry it's not. It may be confusing #bottom
with #bottom.innerHTML
. I'll try to add a test case and patch when I can.
Aww thanks for the prompt feedback! Keep up the good work.
OMG, I finally did some work on this and my tests are passing. Let's hope my code is approved :)