skoppe / spasm

Write single page applications in D that compile to webassembly
MIT License
218 stars 17 forks source link

child content being mishandled #32

Open WebFreak001 opened 5 years ago

WebFreak001 commented 5 years ago

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.

skoppe commented 5 years ago

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.