Skip to content

Commit 8b97725

Browse files
chore: fix $props.id tests (#15294)
* chore: fix `$props.id` tests * chore: reset uid between tests
1 parent b6bf735 commit 8b97725

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

packages/svelte/src/internal/client/dom/template.js

+4
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,10 @@ export function append(anchor, dom) {
252252

253253
let uid = 1;
254254

255+
export function reset_props_id() {
256+
uid = 1;
257+
}
258+
255259
/**
256260
* Create (or hydrate) an unique UID for the component instance.
257261
*/

packages/svelte/tests/runtime-legacy/shared.ts

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { setup_html_equal } from '../html_equal.js';
1111
import { raf } from '../animation-helpers.js';
1212
import type { CompileOptions } from '#compiler';
1313
import { suite_with_variants, type BaseTest } from '../suite.js';
14+
import { reset_props_id } from '../../src/internal/client/dom/template.js';
1415

1516
type Assert = typeof import('vitest').assert & {
1617
htmlEqual(a: string, b: string, description?: string): void;
@@ -345,6 +346,7 @@ async function run_test_variant(
345346

346347
if (runes) {
347348
props = proxy({ ...(config.props || {}) });
349+
reset_props_id();
348350
if (manual_hydrate) {
349351
hydrate_fn = () => {
350352
instance = hydrate(mod.default, {

packages/svelte/tests/runtime-runes/samples/props-id/_config.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ export default test({
4343
`
4444
);
4545
} else {
46-
// `c6` because this runs after the `dom` tests
47-
// (slightly brittle but good enough for now)
4846
assert.htmlEqual(
4947
target.innerHTML,
5048
`
@@ -53,7 +51,7 @@ export default test({
5351
<p>s2</p>
5452
<p>s3</p>
5553
<p>s4</p>
56-
<p>c6</p>
54+
<p>c1</p>
5755
`
5856
);
5957
}

0 commit comments

Comments
 (0)