{"action":"created","issue":{"url":"https://api.github.com/repos/sveltejs/svelte/issues/1793","repository_url":"https://api.github.com/repos/sveltejs/svelte","labels_url":"https://api.github.com/repos/sveltejs/svelte/issues/1793/labels{/name}","comments_url":"https://api.github.com/repos/sveltejs/svelte/issues/1793/comments","events_url":"https://api.github.com/repos/sveltejs/svelte/issues/1793/events","html_url":"https://github.com/sveltejs/svelte/issues/1793","id":373126955,"node_id":"MDU6SXNzdWUzNzMxMjY5NTU=","number":1793,"title":"Data or Store references are not updated correctly inside directive","user":{"login":"hrj","id":345879,"node_id":"MDQ6VXNlcjM0NTg3OQ==","avatar_url":"https://avatars2.githubusercontent.com/u/345879?v=4","gravatar_id":"","url":"https://api.github.com/users/hrj","html_url":"https://github.com/hrj","followers_url":"https://api.github.com/users/hrj/followers","following_url":"https://api.github.com/users/hrj/following{/other_user}","gists_url":"https://api.github.com/users/hrj/gists{/gist_id}","starred_url":"https://api.github.com/users/hrj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hrj/subscriptions","organizations_url":"https://api.github.com/users/hrj/orgs","repos_url":"https://api.github.com/users/hrj/repos","events_url":"https://api.github.com/users/hrj/events{/privacy}","received_events_url":"https://api.github.com/users/hrj/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-10-23T18:00:18Z","updated_at":"2018-10-23T19:12:38Z","closed_at":null,"author_association":"NONE","body":"Consider the following example:\r\n\r\n```\r\n<ul>\r\n{#each plans as plan, idx}\r\n  <li on:click=\"changePlan(idx)\" class:selected=\"planIdx == idx\">{plan.title}</li>\r\n{/each}\r\n</ul>\r\n\r\n<script>\r\n  export default {\r\n    data() {\r\n      return {\r\n        planIdx: 0,\r\n        plans: [{ title: \"Plan 1\" }, { title: \"Plan 2\" }]\r\n      };\r\n    },\r\n    methods: {\r\n      changePlan(idx) {\r\n        console.log(\"changing plan to\", idx);\r\n        this.set({planIdx: idx});\r\n      }\r\n    }\r\n  }\r\n</script>\r\n\r\n<style>\r\n.selected {\r\n  font-weight: bold;\r\n}\r\n</style>\r\n```\r\n\r\nAfter clicking on `Plan2`, it should be highlighted, but it is not. Tested with `2.13.15` and `2.14.2`.\r\n\r\nThe above example uses `data` but the same bug is found with `store` as well.\r\n\r\nIf one of the data elements is part of the rendered HTML, then everything works fine. For example, if we change the HTML above to:\r\n\r\n```\r\n<li on:click=\"changePlan(idx)\" class:selected=\"planIdx == idx\">{plan.title} {planIdx}</li>\r\n```\r\n\r\nthen everything works fine."},"comment":{"url":"https://api.github.com/repos/sveltejs/svelte/issues/comments/432381144","html_url":"https://github.com/sveltejs/svelte/issues/1793#issuecomment-432381144","issue_url":"https://api.github.com/repos/sveltejs/svelte/issues/1793","id":432381144,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMjM4MTE0NA==","user":{"login":"mrkishi","id":150237,"node_id":"MDQ6VXNlcjE1MDIzNw==","avatar_url":"https://avatars1.githubusercontent.com/u/150237?v=4","gravatar_id":"","url":"https://api.github.com/users/mrkishi","html_url":"https://github.com/mrkishi","followers_url":"https://api.github.com/users/mrkishi/followers","following_url":"https://api.github.com/users/mrkishi/following{/other_user}","gists_url":"https://api.github.com/users/mrkishi/gists{/gist_id}","starred_url":"https://api.github.com/users/mrkishi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrkishi/subscriptions","organizations_url":"https://api.github.com/users/mrkishi/orgs","repos_url":"https://api.github.com/users/mrkishi/repos","events_url":"https://api.github.com/users/mrkishi/events{/privacy}","received_events_url":"https://api.github.com/users/mrkishi/received_events","type":"User","site_admin":false},"created_at":"2018-10-23T19:12:38Z","updated_at":"2018-10-23T19:12:38Z","author_association":"CONTRIBUTOR","body":"I don't believe this is correct behavior. Keyed or not, the final DOM should be the same.\r\n\r\nThe difference between the keyed and non-keyed version is that the non-keyed will just reuse whatever's already on the DOM regardless of its current state."}}
{"actor":{"display_login":"mrkishi"}}