spasm icon indicating copy to clipboard operation
spasm copied to clipboard

child content being mishandled

Open WebFreak001 opened this issue 5 years ago • 1 comments

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.

WebFreak001 avatar Aug 18 '19 11:08 WebFreak001

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.

skoppe avatar Aug 18 '19 13:08 skoppe