New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DataTable runtime row type is lost #667
Comments
Also, this merge operation overwrites any <script>
import { DataTable } from "carbon-components-svelte";
const headers = [
{ key: 'organism', value: "Organism" },
{ key: 'cells', value: "Cells" }
];
const rows = [
{ id: 0, organism: "Elegans - Adult male", cells: 1031 },
{ id: 1, organism: "Elegans - Adult hermaphrodite", cells: 959 },
{ id: 2, organism: "Elegans - Hatched larvae", cells: 558 },
];
</script>
<DataTable {headers} {rows} title="row.cells unexpected">
<span slot="cell" let:row let:cell>
{#if cell.key == 'cells'}
{row.cells}
{:else}
{cell.value}
{/if}
</span>
</DataTable> |
@brunnerh Can you provide a simple repo of your use case to illustrate the first problem? |
* refactor(data-table): remove unneeded third argument from resolvePath call * fix(data-table): do not overwrite `cells` property (#667) * perf(data-table): early return if path in object when resolving path
@metonym Do you mean the type being lost? This illustrates two use cases when using classes: REPL
I currently cannot access the original project using proxies, but this should be pretty similar: REPL |
The DataTable component uses a spread operation internally which loses all non-enumerated properties and the original type:
E.g. functions of the prototype will be gone:
I would recommend assigning the original row to a property instead of or additionally to spreading it to prevent this.
In my particular use case the row is a
Proxy
, which becomes mostly useless after the spread. Having the original type might also be useful for type-based operations usinginstanceof
.The text was updated successfully, but these errors were encountered: