mirror of https://github.com/sveltejs/svelte
commit
2ba3a12ab6
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: ensure infinite effect loops are cleared after flushing
|
||||
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: allow `{#key NaN}`
|
||||
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: detect store in each block expression regardless of AST shape
|
||||
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: treat `<menu>` like `<ul>`/`<ol>` for a11y role checks
|
||||
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: add vite-ignore comment inside dynamic crypto import
|
||||
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
chore: wrap JSDoc URLs in `@see` and `@link` tags
|
||||
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': minor
|
||||
---
|
||||
|
||||
feat: allow use of createContext when instantiating components programmatically
|
||||
@ -0,0 +1,5 @@
|
||||
---
|
||||
"svelte": patch
|
||||
---
|
||||
|
||||
fix: properly hydrate already-resolved async blocks
|
||||
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: emit `each_key_duplicate` error in production
|
||||
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: exit resolved async blocks on correct node when hydrating
|
||||
@ -1,115 +0,0 @@
|
||||
name: Update pkg.pr.new comment
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ['Publish Any Commit']
|
||||
types:
|
||||
- completed
|
||||
|
||||
permissions:
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: 'Update comment'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Download artifact
|
||||
uses: actions/download-artifact@v7
|
||||
with:
|
||||
name: output
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
run-id: ${{ github.event.workflow_run.id }}
|
||||
|
||||
- run: ls -R .
|
||||
- name: 'Post or update comment'
|
||||
uses: actions/github-script@v8
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const fs = require('fs');
|
||||
const output = JSON.parse(fs.readFileSync('output.json', 'utf8'));
|
||||
|
||||
const bot_comment_identifier = `<!-- pkg.pr.new comment -->`;
|
||||
|
||||
const body = (number) => `${bot_comment_identifier}
|
||||
|
||||
[Playground](https://svelte.dev/playground?version=pr-${number})
|
||||
|
||||
\`\`\`
|
||||
${output.packages.map((p) => `pnpm add https://pkg.pr.new/${p.name}@${number}`).join('\n')}
|
||||
\`\`\`
|
||||
`;
|
||||
|
||||
async function find_bot_comment(issue_number) {
|
||||
if (!issue_number) return null;
|
||||
const comments = await github.rest.issues.listComments({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issue_number,
|
||||
});
|
||||
return comments.data.find((comment) =>
|
||||
comment.body.includes(bot_comment_identifier)
|
||||
);
|
||||
}
|
||||
|
||||
async function create_or_update_comment(issue_number) {
|
||||
if (!issue_number) {
|
||||
console.log('No issue number provided. Cannot post or update comment.');
|
||||
return;
|
||||
}
|
||||
|
||||
const existing_comment = await find_bot_comment(issue_number);
|
||||
if (existing_comment) {
|
||||
await github.rest.issues.updateComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
comment_id: existing_comment.id,
|
||||
body: body(issue_number),
|
||||
});
|
||||
} else {
|
||||
await github.rest.issues.createComment({
|
||||
issue_number: issue_number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: body(issue_number),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function log_publish_info() {
|
||||
const svelte_package = output.packages.find(p => p.name === 'svelte');
|
||||
const svelte_sha = svelte_package.url.replace(/^.+@([^@]+)$/, '$1');
|
||||
console.log('\n' + '='.repeat(50));
|
||||
console.log('Publish Information');
|
||||
console.log('='.repeat(50));
|
||||
console.log('\nPublished Packages:');
|
||||
console.log(output.packages.map((p) => `${p.name} - pnpm add https://pkg.pr.new/${p.name}@${p.url.replace(/^.+@([^@]+)$/, '$1')}`).join('\n'));
|
||||
if(svelte_sha){
|
||||
console.log('\nPlayground URL:');
|
||||
console.log(`\nhttps://svelte.dev/playground?version=commit-${svelte_sha}`)
|
||||
}
|
||||
console.log('\n' + '='.repeat(50));
|
||||
}
|
||||
|
||||
if (output.event_name === 'pull_request') {
|
||||
if (output.number) {
|
||||
await create_or_update_comment(output.number);
|
||||
}
|
||||
} else if (output.event_name === 'push') {
|
||||
const pull_requests = await github.rest.pulls.list({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
state: 'open',
|
||||
head: `${context.repo.owner}:${output.ref.replace('refs/heads/', '')}`,
|
||||
});
|
||||
|
||||
if (pull_requests.data.length > 0) {
|
||||
await create_or_update_comment(pull_requests.data[0].number);
|
||||
} else {
|
||||
console.log(
|
||||
'No open pull request found for this push. Logging publish information to console:'
|
||||
);
|
||||
await log_publish_info();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { ok, test } from '../../test';
|
||||
|
||||
export default test({
|
||||
test({ assert, target, window }) {
|
||||
const input = target.querySelector('input');
|
||||
ok(input);
|
||||
|
||||
const event = new window.Event('input');
|
||||
input.value = 'changed';
|
||||
input.dispatchEvent(event);
|
||||
flushSync();
|
||||
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`
|
||||
<input>
|
||||
<p>changed</p>
|
||||
`
|
||||
);
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,13 @@
|
||||
<script>
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
const items = writable([
|
||||
{ id: 0, text: 'initial' }
|
||||
]);
|
||||
</script>
|
||||
|
||||
{#each $items ?? [] as item}
|
||||
<input bind:value={item.text}>
|
||||
{/each}
|
||||
|
||||
<p>{$items[0].text}</p>
|
||||
@ -0,0 +1,12 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
test({ assert, target }) {
|
||||
let button = target.querySelector('button');
|
||||
|
||||
button?.click();
|
||||
|
||||
assert.throws(flushSync, 'https://svelte.dev/e/each_key_duplicate');
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,8 @@
|
||||
<script>
|
||||
let data = $state([1, 2, 3]);
|
||||
</script>
|
||||
|
||||
<button onclick={() => data = [1, 1, 1]}>add</button>
|
||||
{#each data as d (d)}
|
||||
{d}
|
||||
{/each}
|
||||
@ -0,0 +1,5 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
error: 'each_key_duplicate'
|
||||
});
|
||||
@ -0,0 +1,7 @@
|
||||
<script>
|
||||
let data = [1, 1, 1];
|
||||
</script>
|
||||
|
||||
{#each data as d (d)}
|
||||
{d}
|
||||
{/each}
|
||||
@ -0,0 +1,12 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
test({ assert, target }) {
|
||||
let button = target.querySelector('button');
|
||||
|
||||
button?.click();
|
||||
|
||||
assert.throws(flushSync, 'https://svelte.dev/e/each_key_duplicate');
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,8 @@
|
||||
<script>
|
||||
let data = $state([1, 2, 3, 4, 5]);
|
||||
</script>
|
||||
|
||||
<button onclick={() => data = [1, 1, 3, 1]}>add</button>
|
||||
{#each data as d (d)}
|
||||
{d}
|
||||
{/each}
|
||||
@ -0,0 +1,4 @@
|
||||
<script>
|
||||
let { children } = $props()
|
||||
</script>
|
||||
<div>{@render children?.()}</div>
|
||||
@ -0,0 +1,4 @@
|
||||
<script>
|
||||
let { children } = $props()
|
||||
</script>
|
||||
<div>{@render children?.()}</div>
|
||||
@ -0,0 +1,7 @@
|
||||
<script lang='ts'>
|
||||
import type { Attachment } from 'svelte/attachments'
|
||||
|
||||
export function action(): Attachment<HTMLElement> {
|
||||
return ()=>{}
|
||||
}
|
||||
</script>
|
||||
@ -0,0 +1,10 @@
|
||||
import { tick } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
mode: ['hydrate'],
|
||||
async test({ assert, target }) {
|
||||
await tick();
|
||||
assert.htmlEqual(target.innerHTML, '<div><div>foo</div></div>');
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,16 @@
|
||||
<script>
|
||||
import Outer from './Outer.svelte'
|
||||
import Inner from './Inner.svelte'
|
||||
import Trigger from './Trigger.svelte'
|
||||
|
||||
const data = $derived(await Promise.resolve(['a', 'b']))
|
||||
let trigger = $state()
|
||||
</script>
|
||||
|
||||
<Outer>
|
||||
<Inner {@attach trigger?.action}>
|
||||
foo
|
||||
</Inner>
|
||||
</Outer>
|
||||
|
||||
<Trigger bind:this={trigger} />
|
||||
@ -0,0 +1,9 @@
|
||||
<script>
|
||||
let { id } = $props();
|
||||
|
||||
// BUG: This logs 'undefined' on unmount when parent has async derived
|
||||
const data = $derived(await Promise.resolve(id).then((x) => {
|
||||
console.log('promise resolved with:', x);
|
||||
return x;
|
||||
}));
|
||||
</script>
|
||||
@ -0,0 +1,16 @@
|
||||
import { tick } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
async test({ assert, target, logs }) {
|
||||
await tick();
|
||||
|
||||
assert.deepEqual(logs, ['promise resolved with:', 'some-id']);
|
||||
|
||||
const button = target.querySelector('button');
|
||||
button?.click();
|
||||
await tick();
|
||||
|
||||
assert.deepEqual(logs, ['promise resolved with:', 'some-id']);
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,14 @@
|
||||
<script>
|
||||
import Child from './Child.svelte';
|
||||
|
||||
// This async derived in parent triggers the bug
|
||||
const something = $derived(await Promise.resolve('test'));
|
||||
|
||||
let active = $state('some-id');
|
||||
</script>
|
||||
|
||||
{#if active}
|
||||
<Child id={active} />
|
||||
{/if}
|
||||
|
||||
<button onclick={() => active = undefined}>close</button>
|
||||
@ -0,0 +1,5 @@
|
||||
<script>
|
||||
let { message, another } = $props()
|
||||
</script>
|
||||
|
||||
<p>{message}</p>
|
||||
@ -0,0 +1,14 @@
|
||||
import { tick } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
mode: ['hydrate'],
|
||||
|
||||
ssrHtml: `<p>item 1</p><p>item 2</p><p>item 3</p>`,
|
||||
html: `<p>item 1</p><p>item 2</p><p>item 3</p>`,
|
||||
|
||||
async test({ assert, target }) {
|
||||
await tick();
|
||||
assert.htmlEqual(target.innerHTML, '<p>item 1</p><p>item 2</p><p>item 3</p>');
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,10 @@
|
||||
<script>
|
||||
import Component from './Component.svelte'
|
||||
|
||||
const messages = await Promise.resolve(["item 1", "item 2", "item 3"])
|
||||
const another = { test: 'test' }
|
||||
</script>
|
||||
|
||||
{#each messages as message}
|
||||
<Component {message} {another} />
|
||||
{/each}
|
||||
@ -0,0 +1,5 @@
|
||||
<script>
|
||||
let { b } = $props();
|
||||
</script>
|
||||
|
||||
{b}
|
||||
@ -0,0 +1,11 @@
|
||||
import { tick } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
mode: ['hydrate'],
|
||||
|
||||
async test({ assert, target }) {
|
||||
await tick();
|
||||
assert.htmlEqual(target.innerHTML, `<div><p>hello</p></div> <div>true</div>`);
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,18 @@
|
||||
<script lang="ts">
|
||||
import Child from "./Child.svelte";
|
||||
|
||||
await 1;
|
||||
let b = true;
|
||||
let a = true;
|
||||
</script>
|
||||
|
||||
{#if a}
|
||||
<div>
|
||||
{#if b}
|
||||
<p>hello</p>
|
||||
{/if}
|
||||
</div>
|
||||
<div>
|
||||
<Child {b} />
|
||||
</div>
|
||||
{/if}
|
||||
@ -0,0 +1,7 @@
|
||||
<script>
|
||||
import { get } from './main.svelte';
|
||||
|
||||
const message = get();
|
||||
</script>
|
||||
|
||||
<h1>{message}</h1>
|
||||
@ -0,0 +1,8 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
ssrHtml: `<div></div>`,
|
||||
html: `<div><h1>hello</h1></div>`,
|
||||
|
||||
test() {}
|
||||
});
|
||||
@ -0,0 +1,20 @@
|
||||
<script module>
|
||||
import { createContext, mount } from 'svelte';
|
||||
import Child from './Child.svelte';
|
||||
|
||||
/** @type {ReturnType<typeof createContext<string>>} */
|
||||
const [get, set] = createContext();
|
||||
|
||||
export { get };
|
||||
|
||||
function Wrapper(Component) {
|
||||
return (...args) => {
|
||||
set('hello');
|
||||
return Component(...args);
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
<div {@attach (target) => {
|
||||
mount(Wrapper(Child), { target });
|
||||
}}></div>
|
||||
@ -0,0 +1,17 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: '<button>update</button><p>it rendered</p>',
|
||||
|
||||
test({ assert, target, logs }) {
|
||||
assert.deepEqual(logs, ['rendering']);
|
||||
|
||||
const btn = target.querySelector('button');
|
||||
flushSync(() => btn?.click());
|
||||
|
||||
// should not re-render
|
||||
assert.deepEqual(logs, ['rendering']);
|
||||
assert.htmlEqual(target.innerHTML, '<button>update</button><p>it rendered</p>');
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,10 @@
|
||||
<script>
|
||||
let x = $state(NaN);
|
||||
</script>
|
||||
|
||||
<button onclick={() => x = NaN}>update</button>
|
||||
|
||||
{#key x}
|
||||
{console.log('rendering')}
|
||||
<p>it rendered</p>
|
||||
{/key}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue