mirror of https://github.com/sveltejs/svelte
commit
74f54502fa
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: avoid declaration tag warning in event handlers
|
||||
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: chain preprocessor sourcemaps with an empty `sources[0]` instead of dropping them
|
||||
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: don't treat declaration tags as parts inside each blocks
|
||||
@ -0,0 +1,10 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
async test({ target, assert }) {
|
||||
const [btn1, btn2] = target.querySelectorAll('button');
|
||||
flushSync(() => btn2.click());
|
||||
assert.equal(btn1.textContent, '1');
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,6 @@
|
||||
{#each Array(1)}
|
||||
{let ref = $state()}
|
||||
{let count = $state(0)}
|
||||
<button onclick={()=>count++} bind:this={ref}>{count}</button>
|
||||
<button onclick={()=>ref.click()}></button>
|
||||
{/each}
|
||||
@ -0,0 +1,29 @@
|
||||
import * as fs from 'node:fs';
|
||||
import MagicString from 'magic-string';
|
||||
import { test } from '../../test';
|
||||
|
||||
// Simulates a bundler plugin (e.g. a Vite plugin using `magic-string`) that transforms
|
||||
// the Svelte source *before* it reaches `compile()`, and hands its own sourcemap to
|
||||
// `compileOptions.sourcemap` — the documented way to let svelte chain an upstream map
|
||||
// into its own output map. Crucially, the upstream map is generated *without* a `source`
|
||||
// option, exactly like `new MagicString(code).generateMap()` — this yields a sourcemap
|
||||
// whose `sources` is `['']`, which previously broke the chain entirely (see #18491)
|
||||
// instead of being treated as "this file", causing every mapping through it to resolve
|
||||
// to `{ source: null, line: null, column: null }`.
|
||||
const input = fs.readFileSync(new URL('./input.svelte', import.meta.url), 'utf-8');
|
||||
const src = new MagicString(input);
|
||||
src.overwrite(
|
||||
src.original.indexOf('count * 2'),
|
||||
src.original.indexOf('count * 2') + 'count * 2'.length,
|
||||
'count * 2',
|
||||
{
|
||||
storeName: false
|
||||
}
|
||||
);
|
||||
|
||||
export default test({
|
||||
compileOptions: {
|
||||
sourcemap: src.generateMap({ hires: true })
|
||||
},
|
||||
client: [{ str: 'let doubled' }]
|
||||
});
|
||||
@ -0,0 +1,6 @@
|
||||
<script>
|
||||
let count = 0;
|
||||
let doubled = count * 2;
|
||||
</script>
|
||||
|
||||
<button>clicks: {count}</button>
|
||||
Loading…
Reference in new issue