Skip to content
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

svelte-table impacted by bug in Svelte > 3.39.0 #68

Closed
wtfiwtz opened this issue Dec 4, 2021 · 2 comments
Closed

svelte-table impacted by bug in Svelte > 3.39.0 #68

wtfiwtz opened this issue Dec 4, 2021 · 2 comments

Comments

@wtfiwtz
Copy link

wtfiwtz commented Dec 4, 2021

The distribution versions of svelte-table are compiled with svelte > 3.39.0 which has this issue:

sveltejs/svelte#6584
Introduced here: sveltejs/svelte#5870

The easiest workaround I found was to directly import the .svelte file. Change:
import SvelteTable from "svelte-table";
to
import SvelteTable from "svelte-table/src/SvelteTable.svelte";

This gets around the use of the dist/ folder versions in the NPM package.

Here's where you can hack the dist/es/SvelteTable.mjs file to confirm:

function Y(t, n, c, s, r, a, i, d = [-1]) {
    const u = O;
    S(t);
    const f = t.$$ = {
        fragment: null,
        ctx: null,
        props: a,
        update: e,
        not_equal: r,
        bound: o(),
        on_mount: [],
        on_destroy: [],
        on_disconnect: [],
        before_update: [],
        after_update: [],
        context: new Map(n.context || (u ? u.$$.context : [])),
        callbacks: o(),
        dirty: d,
        skip_bound: !1,
        root: n.target || (u && u.$$.root)
    };

... to add u && u.$$.root. This is be the parent_component pointer is not checked - see sveltejs/svelte@5cfefeb#diff-da9bae4e28c441de5ba3a074e30775fe69109100b3d921ad8f2592d93cd67b7fR133.

The error is:

SvelteTable.mjs:404 
Uncaught TypeError: Cannot read properties of undefined (reading '$$')
    at Y (SvelteTable.mjs:404)
    at new Ce (SvelteTable.mjs:1411)
    at Array.create_default_slot_13 (Board.svelte:138)
    at create_slot (index.mjs:141)
    at create_fragment (CardBody.svelte:2)
    at init (index.mjs:2129)
    at new CardBody (CardBody.svelte:7)
    at Array.create_default_slot_12 (Board.svelte:138)
    at create_slot (index.mjs:141)
    at create_fragment (Card.svelte:2)
@dasDaniel
Copy link
Owner

is that better than just rolling back to 3.38.0?

@wtfiwtz
Copy link
Author

wtfiwtz commented Dec 7, 2021

Hi @dasDaniel,

I'm not sure if there is any trade-off in using the distribution version, compared to the .svelte component directly. I guess if you leave it 'as is' then it's up to the developer to switch versions when they are ready to do so.

Of course, if you revert back to 3.38.0 then any new adopters of the svelte-table control won't strike this issue upfront. It might be dependant on different scenarios though... I was using WebPack (on RoR - the svelte-rails gem) with NodeJS 14 (which uses .mjs) where as users on SvelteKit / rollup may not experience this problem.
(I'm not sure specifically why I'm the first person to encounter this issue 😉 )

Cheers,
Nigel

This was referenced Dec 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants