6 of 6 standards met
This is a follow-up to #17852. I was expecting it to resolve an issue that manifests in production, but somehow between my initial debugging and the merged fix something diverged and the issue still reproduces. Video of issue that prompted the original pr as well as this one: Before: https://github.com/user-attachments/assets/00847fe1-ed69-42ce-825f-700cbcd50e26 With this fix: https://github.com/user-attachments/assets/1932d049-82a6-4bd8-805a-2aed474b67f0 AI Explanation** When a branch effect (, ) is destroyed, deriveds inside it must not re-evaluate โ the branch scope is gone and computed values will be stale or throw. The immediate trigger was bind:this teardown: destroying a component with bind:this schedules a microtask that calls get_value on the element binding. If the bound element was inside a child component rendered from a derived in an block that just became false, the derived would re-run with undefined and crash (e.g. calling on undefined). Root cause: returns null for destroyed parent effects, so sees and proceeds to re-evaluate. The fix walks the .parent chain directly to detect whether the nearest non-derived ancestor is a that has been , and returns the cached value instead. Tests: adds a component integration test (runtime-runes) that exercises the exact pattern, and a low-level signal unit test that directly sets up the block โ branch โ derived teardown sequence to confirm no re-evaluation occurs after destruction. Before submitting the PR, please make sure you do the following [ ] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs [x] Prefix your PR title with , , , or . [x] This message body should clearly illustrate what problems it solves. [x] Ideally, include a test that fails without this PR but passes with it. [x] If this PR changes code within , add a changeset (). Tests and linting [x] Run the tests with and lint the project with
Repository: sveltejs/svelte. Description: web development for the rest of us Stars: 86024, Forks: 4798. Primary language: JavaScript. Languages: JavaScript (71.8%), Svelte (22.3%), TypeScript (4.2%), CSS (1.2%), HTML (0.5%). License: MIT. Homepage: https://svelte.dev Topics: compiler, template, ui. Latest release: svelte@5.53.7 (4d ago). Open PRs: 61, open issues: 915. Last activity: 17h ago. Community health: 87%. Top contributors: Rich-Harris, Conduitry, dummdidumm, github-actions[bot], trueadm, tanhauhau, benmccann, paoloricciuti, PuruVJ, baseballyama and others.
JavaScript
Last 12 weeks ยท 249 commits
This simplifies the scheduling logic and will likely improve performance in some cases. Previously, there was a global array, and we would cycle through the batch flushing logic as long as it was non-empty. This was a very loosey-goosey approach that was appropriate in the pre-async world, but has gradually become a source of confusion. Now, effects are scheduled within the context of a specific batch. The lifecycle is more rigorous and debuggable. This opens the door to explorations of alternative approaches, such as only scheduling effects when we call , which _may_ be better than the eager status quo. The layout of the class is extremely chaotic โ public/private/static fields/methods are all jumbled up together โ and I would like to get a grip of it. In the interests of minimising diff noise that ought to be a follow-up rather than part of this PR. Before submitting the PR, please make sure you do the following [x] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs [x] Prefix your PR title with , , , or . [x] This message body should clearly illustrate what problems it solves. [ ] Ideally, include a test that fails without this PR but passes with it. [x] If this PR changes code within , add a changeset (). Tests and linting [x] Run the tests with and lint the project with
https://github.com/sveltejs/svelte/pull/17596#pullrequestreview-3767879312. Blocked on: https://github.com/oxc-project/oxc/issues/15538 https://github.com/oxc-project/oxc/issues/12018 https://github.com/oxc-project/oxc/issues/14826#issuecomment-3770594680 https://github.com/oxc-project/oxc/issues/14826#issuecomment-3865457837
Fixes content duplication when used inside a contenteditable element. When is inside a contenteditable element and the user types, the browser inserts DOM nodes directly into the {@html} managed region. On re-render (e.g. triggered by a blur handler setting , the block only removed nodes it previously created via, leaving browser-inserted nodes in place. This caused content to appear twice โ once as leftover text nodes and once as the new output. The fix tracks the boundary node (of the anchor at init) and removes all nodes between the boundary and the anchor on re-render, ensuring externally-added nodes are also cleaned up. Closes: #16993 Before submitting the PR, please make sure you do the following [x] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs [x] Prefix your PR title with , , , or . [x] This message body should clearly illustrate what problems it solves. [x] Ideally, include a test that fails without this PR but passes with it. [x] If this PR changes code within , add a changeset (). Tests and linting [x] Run the tests with and lint the project with