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

Another 1.56 context bug #1206

Closed
Rich-Harris opened this issue Mar 5, 2018 · 2 comments · Fixed by #1220
Closed

Another 1.56 context bug #1206

Rich-Harris opened this issue Mar 5, 2018 · 2 comments · Fixed by #1220
Labels

Comments

@Rich-Harris
Copy link
Member

Via StackOverflow:

<p><input bind:value=search></p>

{{#each categories.filter(predicate) as category}}
  <!-- the click event should work, right? -->
    <button on:click='console.log(category)'>{{category}}</button>
{{/each}}

<script>
    export default {
        data() {
            return {
                search: '',
                categories: [
                    'animal',
                    'vegetable',
                    'mineral'
                ]
            }
        },
      computed: {
            predicate: search => {
                search = search.toLowerCase();
                return word => word.startsWith(search);
            }
        }
    };
</script>

REPL.

@Rich-Harris Rich-Harris added the bug label Mar 5, 2018
@tivac
Copy link
Contributor

tivac commented Mar 6, 2018

Poked around in the REPL, dunno if this is helpful but here goes nothing.

https://gist.github.com/tivac/7c74c2b8f8927612b4f057ad16d5e782#file-output-js-L33-L36

create_main_fragment is calling create_each_block and passing it a category and a category_index in the state object.

https://gist.github.com/tivac/7c74c2b8f8927612b4f057ad16d5e782#file-output-js-L132-L154

create_each_value is then setting button._svelte to have a each_value and category_index, even though state.each_value doesn't exist. This happens in both the p and h.

https://gist.github.com/tivac/7c74c2b8f8927612b4f057ad16d5e782#file-output-js-L167-L170

Then when the event handler fires this._svelte.each_value is undefined and everything goes real bad.

@Rich-Harris
Copy link
Member Author

fixed in 1.57.1, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants