Riot.js Bug Report Template
by gianlucaguarini
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/riot/2.6.3/riot+compiler.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/riot/2.6.5/riot+compiler.js"></script>
<app></app>
<script type="riot/tag">
<partial>
<span>{JSON.stringify(opts.obj)}</span>
this.on('unmount', () => console.log(`unmounted ${JSON.stringify(opts.obj)}`))
</partial>
<app>
<!-- (1) Doing it this way causes the partial to be unmounted immediately -->
<div each={o in this.objects} style="min-height: 1em; background-color: aqua;">
<partial obj="{o}" />
</div>
<!-- (2) Doing it this way works: -->
<div>
<partial each={o in this.objects} obj="{o}"/>
</div>
<!-- (3) Removing this line causes (1) to start working -->
<partial each={this.newobj ? [this.newobj] : []} obj="{this.parent.newobj}"/>
<button onclick={this.save}>Save</button>
this.objects = [];
this.newobj = {};
this.save = () => {
if (this.newobj) this.newobj.pushed = true;
this.objects.push(this.newobj);
this.newobj = null;
this.update();
}
</app>
</script>
CSS
body {
font-family: sans-serif;
}
JavaScript
/**
* Riot.js is loaded from External Resources
* https://cdnjs.cloudflare.com/ajax/libs/riot/2.6.5/riot+compiler.js
*/
riot.mount('app')