svelte icon indicating copy to clipboard operation
svelte copied to clipboard

set_custom_element_data: Cannot use 'in' operator to search for 'item' in undefined

Open TommasoAmici opened this issue 3 years ago • 9 comments

Describe the bug

After upgrading from 3.44.2 to 3.44.3 one of the components I work on has broken with this error.

We use svelte to output custom elements.

Reproduction

https://github.com/TommasoAmici/svelte-error

Logs

Uncaught TypeError: Cannot use 'in' operator to search for 'item' in undefined

image

function set_custom_element_data(node, prop, value) {
    if (prop in node) {
        node[prop] = typeof node[prop] === 'boolean' && value === '' ? true : value;
    }
    else {
        attr(node, prop, value);
    }
}

System Info

System:
    OS: macOS 11.6
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 706.83 MB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.13.1 - /usr/local/Cellar/node@16/16.13.1/bin/node
    Yarn: 1.22.17 - /usr/local/bin/yarn
    npm: 8.1.2 - /usr/local/Cellar/node@16/16.13.1/bin/npm
    Watchman: 2021.12.20.00 - /usr/local/bin/watchman
  Browsers:
    Chrome: 96.0.4664.110
    Edge: 96.0.1054.62
    Firefox Developer Edition: 96.0
    Safari: 15.2
    Safari Technology Preview: 15.4
  npmPackages:
    rollup: ^2.61.1 => 2.61.1 
    svelte: ^3.44.3 => 3.44.3

Severity

blocking an upgrade

TommasoAmici avatar Dec 21 '21 13:12 TommasoAmici

This is also blocking for me. Is there any response or update? Thanks!

ssuess avatar Feb 16 '22 11:02 ssuess

This is still happening as of 3.46.6

TommasoAmici avatar Apr 04 '22 11:04 TommasoAmici

We maintain a library of web components made in Svelte, and this issue is blocking an upgrade for us.

This issue seems to have been introduced with this PR:
https://github.com/sveltejs/svelte/pull/6073

abdullahkamran avatar Apr 13 '22 05:04 abdullahkamran

Is there no fix for this yet?

ssuess avatar Apr 13 '22 05:04 ssuess

Is someone able to provide a smaller reproduction for this? The linked repo contains 400+ lines of component code and Storybook, which will make it difficult to pinpoint the issue.

I doubt it was introduced by #6073, since a) the error is thrown before the line that PR changed and b) that change was released in 3.38.0, where this issue was introduced with 3.44.3.

geoffrich avatar Apr 13 '22 15:04 geoffrich

Any progress on this issue? As a workaround I am doing for every array refresh instead of list=list

    setTimeout(function() {           
        list=list
        },200)  

in my project. I have this now on many places in my application - makes current Svelte version not very usable to be honest.

imperator-maximus avatar Jan 09 '23 11:01 imperator-maximus

In case this helps anyone we are testing a fix (that has its own issues still) where we replace our repeating component with <svelte:self > and it seems promising

ssuess avatar Jan 09 '23 14:01 ssuess

@imperator-maximus @ssuess please see my comment above - we need a smaller reproduction to properly investigate this issue.

geoffrich avatar Jan 09 '23 15:01 geoffrich

I cannot provide one: it seems that this only occurs in very large projects. If projects are smaller I never had such an issue.

imperator-maximus avatar Jan 09 '23 15:01 imperator-maximus