spasm
spasm copied to clipboard
child content being mishandled
I want to mix an element and a text node so I tried the following code:
struct Elem
{
mixin Node!"div";
@prop innerText = "elem";
}
struct App
{
mixin Node!"div";
@prop innerText = "app";
@child Elem elem;
}
mixin Spa!App;
and expected
app
<div>elem</div>
but instead got
app
<div>app</div>
which I can't explain to myself.
Changing one to textContent and the other to innerText (but not both the same) seems to fix this but that feels like a hack.
I thought maybe adding a @child something = "test";
instead of the innerText prop might be properly handled as text node, but instead that only gave me compilation errors.
which I can't explain to myself.
I will figure out why that is happening.
I know that doing a innerText
, innerHTML
or textContent
causes the rest of the content of the node to be emptied.
You are right that @child something = "test";
should actually create a text node. I thought about that as well.