Skip to content

Handle slot updates where parent component has many variables#4078

Merged
Rich-Harris merged 5 commits intomasterfrom
bitmask-overflow-slot
Dec 10, 2019
Merged

Handle slot updates where parent component has many variables#4078
Rich-Harris merged 5 commits intomasterfrom
bitmask-overflow-slot

Conversation

@Rich-Harris
Copy link
Copy Markdown
Member

No related issue because the problem and solution only revealed themselves in the making of this PR.

Basically, in a situation like this...

<SomeComponent let:foo>
  {foo}
</SomeComponent>

...where the parent component has enough dynamic variables that it needs to use an array of bitmasks, the {foo} in the slot doesn't get updated. That's because the function that merges the slot scope with the ambient scope is doing bitwise operations on arrays.

This PR fixes it. I can't pretend it's the most elegant piece of code ever written, but short of a more comprehensive change to the order of operations, it's probably about as good as we can get.

@ghost
Copy link
Copy Markdown

ghost commented Dec 10, 2019

@Rich-Harris,

Do you think this will also clear up #4077?
It looks like you made changes to the code that @mrkishi and I were looking at for that bug.

@Conduitry
Copy link
Copy Markdown
Member

That would be a lot easier to answer if there were a reproduction for #4077.

@antony
Copy link
Copy Markdown
Member

antony commented Dec 10, 2019

@Conduitry @dkondrad I've tried this branch with my repro from #4077 and sadly it doesn't fix it.

Edit: Somebody might want to check my work since I simply npm install --save-dev sveltejs/svelte#bitmask-overflow-slot to do this, and I'm not sure if there's more to it.

ant@xeno  ~/Projects/bitflow  npm run dev                    

> svelte-app@1.0.0 dev /home/ant/Projects/bitflow
> rollup -c -w

rollup v1.27.9
bundles src/main.js → public/build/bundle.js...
[!] (plugin svelte) TypeError: Cannot read property 'n' of undefined
src/App.svelte
TypeError: Cannot read property 'n' of undefined
    at Object.get expression [as expression] (/home/ant/Projects/bitflow/node_modules/svelte/compiler.js:12072:62)
    at visit (/home/ant/Projects/bitflow/node_modules/svelte/compiler.js:300:25)
    at visit (/home/ant/Projects/bitflow/node_modules/svelte/compiler.js:318:5)
    at visit (/home/ant/Projects/bitflow/node_modules/svelte/compiler.js:309:12)
    at visit (/home/ant/Projects/bitflow/node_modules/svelte/compiler.js:318:5)
    at visit (/home/ant/Projects/bitflow/node_modules/svelte/compiler.js:318:5)
    at visit (/home/ant/Projects/bitflow/node_modules/svelte/compiler.js:309:12)
    at visit (/home/ant/Projects/bitflow/node_modules/svelte/compiler.js:318:5)
    at visit (/home/ant/Projects/bitflow/node_modules/svelte/compiler.js:309:12)
    at visit (/home/ant/Projects/bitflow/node_modules/svelte/compiler.js:309:12)

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

Successfully merging this pull request may close these issues.

3 participants