-
Notifications
You must be signed in to change notification settings - Fork 414
Closed
Labels
Description
Description
I noticed that the static optimization (#2781) broke the js-framework-benchmark. It throws an error when trying to append elements.
The problem is that the compiled template ends up with this code:
const $fragment2 = parseFragment`<td class="col-md-6${0}"${2}></td>`;
And eventually it tries to parse this html into a fragment using this function:
lwc/packages/@lwc/engine-dom/src/renderer.ts
Lines 107 to 109 in c828bfe
function createFragment(html: string): Node | null { | |
return document.createRange().createContextualFragment(html).firstChild; | |
} |
But since the <td>
is standalone, this function returns null
:
<template>
<button onclick={add}>Create row</button>
<table>
<tbody>
<template for:each={rows} for:item="row">
<tr key={row.id}>
<td></td>
</tr>
</template>
</tbody>
</table>
</template>
import { LightningElement, track } from 'lwc';
export default class extends LightningElement {
@track rows = [];
add() {
this.rows.push({ id: 1 });
}
}