diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000000..ea6e0f5a60 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,28 @@ +name: Docs + +on: + push: + branches: + - master + paths: + - site/content/** + +jobs: + release: + name: Deploy docs + runs-on: ubuntu-latest + steps: + - name: my-app-install token + id: github-app + uses: getsentry/action-github-app-token@v1 + with: + app_id: ${{ secrets.GH_APP_ID }} + private_key: ${{ secrets.GH_APP_PRIVATE_KEY }} + + - name: run deploy docs workflow + uses: 'sveltejs/action-deploy-docs/dispatch@main' + with: + repo: 'svelte' + branch: 'master' + docs_path: 'site/content' + token: ${{ steps.github-app.outputs.token }} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 56390f7b25..665393d98e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,38 @@ # Svelte changelog +## 3.42.2 + +* Collapse whitespace in `class` and `style` attributes ([#6004](https://github.com/sveltejs/svelte/issues/6004)) +* Deselect all ` + + + + +

selected: null

+ `, + + async test({ assert, component, target }) { + const select = target.querySelector('select'); + const options = [...target.querySelectorAll('option')]; + + assert.equal(component.selected, null); + + // no option should be selected since none of the options matches the bound value + assert.equal(select.value, ''); + assert.equal(select.selectedIndex, -1); + assert.ok(!options[0].selected); + + component.selected = 'a'; // first option should now be selected + assert.equal(select.value, 'a'); + assert.ok(options[0].selected); + + assert.htmlEqual(target.innerHTML, ` +

selected: a

+ + + +

selected: a

+ `); + + component.selected = 'd'; // doesn't match an option + + // now no option should be selected again + assert.equal(select.value, ''); + assert.equal(select.selectedIndex, -1); + assert.ok(!options[0].selected); + + assert.htmlEqual(target.innerHTML, ` +

selected: d

+ + + +

selected: d

+ `); + } +}; diff --git a/test/runtime/samples/binding-select-unmatched/main.svelte b/test/runtime/samples/binding-select-unmatched/main.svelte new file mode 100644 index 0000000000..20e13f4765 --- /dev/null +++ b/test/runtime/samples/binding-select-unmatched/main.svelte @@ -0,0 +1,14 @@ + + +

selected: {selected}

+ + + +

selected: {selected}

\ No newline at end of file diff --git a/test/runtime/samples/destructured-props-1/A.svelte b/test/runtime/samples/destructured-props-1/A.svelte new file mode 100644 index 0000000000..d1b392ef34 --- /dev/null +++ b/test/runtime/samples/destructured-props-1/A.svelte @@ -0,0 +1,24 @@ + + +
+a: {a}, +b: {typeof b}, +c: {c}, +d_one: {d_one}, +d_three: {$d_three}, +f: {f}, +g: {g}, +e: {typeof e}, +e_one: {e_one}, +A: {A}, +C: {C} +
+
{JSON.stringify(THING)}
\ No newline at end of file diff --git a/test/runtime/samples/destructured-props-1/_config.js b/test/runtime/samples/destructured-props-1/_config.js new file mode 100644 index 0000000000..29feaaabab --- /dev/null +++ b/test/runtime/samples/destructured-props-1/_config.js @@ -0,0 +1,9 @@ +export default { + html: ` +
a: 1, b: undefined, c: 2, d_one: 3, d_three: 5, f: undefined, g: 9, e: undefined, e_one: 6, A: 1, C: 2
+
{"a":1,"b":{"c":2,"d":[3,4,{}]},"e":[6],"h":8}
+
+
a: a, b: undefined, c: 2, d_one: d_one, d_three: 5, f: f, g: g, e: undefined, e_one: 6, A: 1, C: 2
+
{"a":1,"b":{"c":2,"d":[3,4,{}]},"e":[6],"h":8}
+ ` +}; diff --git a/test/runtime/samples/destructured-props-1/main.svelte b/test/runtime/samples/destructured-props-1/main.svelte new file mode 100644 index 0000000000..dbe7c88d33 --- /dev/null +++ b/test/runtime/samples/destructured-props-1/main.svelte @@ -0,0 +1,7 @@ + + + +
+
diff --git a/test/runtime/samples/destructured-props-2/A.svelte b/test/runtime/samples/destructured-props-2/A.svelte new file mode 100644 index 0000000000..51167edbc4 --- /dev/null +++ b/test/runtime/samples/destructured-props-2/A.svelte @@ -0,0 +1,21 @@ + + +
+ x: {x}, + list_two_a: {list_two_a}, + list_two_b: {list_two_b}, + y: {$y}, + m: {m}, + n: {n}, + o: {o}, + p: {p}, + q: {$q} +
+
{JSON.stringify(LIST)}
\ No newline at end of file diff --git a/test/runtime/samples/destructured-props-2/_config.js b/test/runtime/samples/destructured-props-2/_config.js new file mode 100644 index 0000000000..c647f31be1 --- /dev/null +++ b/test/runtime/samples/destructured-props-2/_config.js @@ -0,0 +1,19 @@ +export default { + html: ` +
x: 1, list_two_a: 2, list_two_b: 5, y: 4, m: 1, n: 2, o: 5, p: 3, q: 4
+
[1,{"a":2},[3,{}]]
+
x: 1, list_two_a: 2, list_two_b: 5, y: 4, m: m, n: n, o: o, p: p, q: q
+
[1,{"a":2},[3,{}]]
+ `, + + async test({ component, assert, target }) { + await component.update(); + + assert.htmlEqual(target.innerHTML, ` +
x: 1, list_two_a: 2, list_two_b: 5, y: 4, m: 1, n: 2, o: 5, p: 3, q: 4
+
[1,{"a":2},[3,{}]]
+
x: 1, list_two_a: 2, list_two_b: 5, y: 4, m: MM, n: NN, o: OO, p: PP, q: QQ
+
[1,{"a":2},[3,{}]]
+ `); + } +}; diff --git a/test/runtime/samples/destructured-props-2/main.svelte b/test/runtime/samples/destructured-props-2/main.svelte new file mode 100644 index 0000000000..f0044bb567 --- /dev/null +++ b/test/runtime/samples/destructured-props-2/main.svelte @@ -0,0 +1,30 @@ + + +
+
+
diff --git a/test/runtime/samples/destructured-props-3/A.svelte b/test/runtime/samples/destructured-props-3/A.svelte new file mode 100644 index 0000000000..6c5aca05b0 --- /dev/null +++ b/test/runtime/samples/destructured-props-3/A.svelte @@ -0,0 +1,10 @@ + + +
i: {i}, j: {j}, k: {$k}, l: {l}, m: {m}, n: {$n}, a: {a}, b: {b}, c: {$c}, d: {d}, e: {e}, f: {$f}
\ No newline at end of file diff --git a/test/runtime/samples/destructured-props-3/_config.js b/test/runtime/samples/destructured-props-3/_config.js new file mode 100644 index 0000000000..6d2e516e0e --- /dev/null +++ b/test/runtime/samples/destructured-props-3/_config.js @@ -0,0 +1,15 @@ +export default { + html: ` +
i: 9, j: 10, k: 11, l: 12, m: 13, n: 14, a: 9, b: 10, c: 11, d: 12, e: 13, f: 14
+
+
i: 9, j: 10, k: 11, l: 12, m: 13, n: 14, a: a, b: 10, c: c, d: d, e: 13, f: f
+ `, + async test({ component, target, assert }) { + await component.update(); + assert.htmlEqual(target.innerHTML, ` +
i: 9, j: 10, k: 11, l: 12, m: 13, n: 14, a: 9, b: 10, c: 11, d: 12, e: 13, f: 14
+
+
i: 9, j: 10, k: 11, l: 12, m: 13, n: 14, a: aa, b: 10, c: cc, d: dd, e: 13, f: ff
+ `); + } +}; diff --git a/test/runtime/samples/destructured-props-3/main.svelte b/test/runtime/samples/destructured-props-3/main.svelte new file mode 100644 index 0000000000..8152d61aab --- /dev/null +++ b/test/runtime/samples/destructured-props-3/main.svelte @@ -0,0 +1,29 @@ + + +
+
+
diff --git a/test/runtime/samples/export-from/A.svelte b/test/runtime/samples/export-from/A.svelte new file mode 100644 index 0000000000..7773727704 --- /dev/null +++ b/test/runtime/samples/export-from/A.svelte @@ -0,0 +1,23 @@ + + + + +a: {typeof a}
+b: {typeof b}
+c: {typeof c}
+d: {typeof d}
+e: {typeof e}
+f: {typeof f}
+g: {typeof g}
\ No newline at end of file diff --git a/test/runtime/samples/export-from/B.svelte b/test/runtime/samples/export-from/B.svelte new file mode 100644 index 0000000000..0cc1070cb5 --- /dev/null +++ b/test/runtime/samples/export-from/B.svelte @@ -0,0 +1,8 @@ + diff --git a/test/runtime/samples/export-from/_config.js b/test/runtime/samples/export-from/_config.js new file mode 100644 index 0000000000..9e65b7501d --- /dev/null +++ b/test/runtime/samples/export-from/_config.js @@ -0,0 +1,28 @@ +export default { + html: ` + a,b,undefined,c +
+ a: undefined
+ b: number
+ c: undefined
+ d: undefined
+ e: number
+ f: undefined
+ g: undefined
+
+ {"d":"d","e":"e","g":"f"} + `, + ssrHtml: ` + a,b,undefined,c +
+ a: undefined
+ b: number
+ c: undefined
+ d: undefined
+ e: number
+ f: undefined
+ g: undefined
+
+ {} + ` +}; diff --git a/test/runtime/samples/export-from/main.svelte b/test/runtime/samples/export-from/main.svelte new file mode 100644 index 0000000000..18cc066c1f --- /dev/null +++ b/test/runtime/samples/export-from/main.svelte @@ -0,0 +1,21 @@ + + +{a},{b},{c},{d} +
+
+
+{JSON.stringify(props)} \ No newline at end of file diff --git a/test/runtime/samples/key-block-post-hydrate/_config.js b/test/runtime/samples/key-block-post-hydrate/_config.js new file mode 100644 index 0000000000..e989d678e9 --- /dev/null +++ b/test/runtime/samples/key-block-post-hydrate/_config.js @@ -0,0 +1,19 @@ +export default { + html: ` +
+
item 1something
+
item 2something
+
item 3something
+
+ `, + test({ assert, component, target }) { + component.sortById = false; + assert.htmlEqual( target.innerHTML, ` +
+
item 3something
+
item 2something
+
item 1something
+
+ `); + } +}; diff --git a/test/runtime/samples/key-block-post-hydrate/main.svelte b/test/runtime/samples/key-block-post-hydrate/main.svelte new file mode 100644 index 0000000000..8ea316a0d7 --- /dev/null +++ b/test/runtime/samples/key-block-post-hydrate/main.svelte @@ -0,0 +1,23 @@ + + +
+ {#each items as item (item.id)} +
+ {#if item.name} + + {item.name} + + {/if} + something +
+ {/each} +
diff --git a/test/runtime/samples/store-assignment-updates-destructure/_config.js b/test/runtime/samples/store-assignment-updates-destructure/_config.js new file mode 100644 index 0000000000..7a1023614c --- /dev/null +++ b/test/runtime/samples/store-assignment-updates-destructure/_config.js @@ -0,0 +1,11 @@ +export default { + html: ` +
$userName1: user1
+
$userName2: undefined
+
$userName3: undefined
+
$userName4: user4
+
$userName5: undefined
+
$userName6: user6
+
$userName7: undefined
+ ` +}; diff --git a/test/runtime/samples/store-assignment-updates-destructure/main.svelte b/test/runtime/samples/store-assignment-updates-destructure/main.svelte new file mode 100644 index 0000000000..71e02fe16d --- /dev/null +++ b/test/runtime/samples/store-assignment-updates-destructure/main.svelte @@ -0,0 +1,34 @@ + + +
$userName1: {$userName1}
+
$userName2: {$userName2}
+
$userName3: {$userName3}
+
$userName4: {$userName4}
+
$userName5: {$userName5}
+
$userName6: {$userName6}
+
$userName7: {$userName7}
diff --git a/test/runtime/samples/target-dom-detached/App.svelte b/test/runtime/samples/target-dom-detached/App.svelte new file mode 100644 index 0000000000..251e480307 --- /dev/null +++ b/test/runtime/samples/target-dom-detached/App.svelte @@ -0,0 +1,11 @@ + + +
Hello {name}
+ + \ No newline at end of file diff --git a/test/runtime/samples/target-dom-detached/_config.js b/test/runtime/samples/target-dom-detached/_config.js new file mode 100644 index 0000000000..b63656530c --- /dev/null +++ b/test/runtime/samples/target-dom-detached/_config.js @@ -0,0 +1,16 @@ +export default { + skip_if_ssr: true, + compileOptions: { + cssHash: () => 'svelte-xyz' + }, + async test({ assert, component, target, window }) { + assert.htmlEqual( + window.document.head.innerHTML, + '' + ); + assert.htmlEqual( + component.div.innerHTML, + '
Hello World
' + ); + } +}; diff --git a/test/runtime/samples/target-dom-detached/main.svelte b/test/runtime/samples/target-dom-detached/main.svelte new file mode 100644 index 0000000000..42e7dffee9 --- /dev/null +++ b/test/runtime/samples/target-dom-detached/main.svelte @@ -0,0 +1,18 @@ + diff --git a/test/runtime/samples/target-dom/App.svelte b/test/runtime/samples/target-dom/App.svelte new file mode 100644 index 0000000000..251e480307 --- /dev/null +++ b/test/runtime/samples/target-dom/App.svelte @@ -0,0 +1,11 @@ + + +
Hello {name}
+ + \ No newline at end of file diff --git a/test/runtime/samples/target-dom/_config.js b/test/runtime/samples/target-dom/_config.js new file mode 100644 index 0000000000..b63656530c --- /dev/null +++ b/test/runtime/samples/target-dom/_config.js @@ -0,0 +1,16 @@ +export default { + skip_if_ssr: true, + compileOptions: { + cssHash: () => 'svelte-xyz' + }, + async test({ assert, component, target, window }) { + assert.htmlEqual( + window.document.head.innerHTML, + '' + ); + assert.htmlEqual( + component.div.innerHTML, + '
Hello World
' + ); + } +}; diff --git a/test/runtime/samples/target-dom/main.svelte b/test/runtime/samples/target-dom/main.svelte new file mode 100644 index 0000000000..68d2990552 --- /dev/null +++ b/test/runtime/samples/target-dom/main.svelte @@ -0,0 +1,18 @@ + + +
\ No newline at end of file diff --git a/test/runtime/samples/target-shadow-dom/App.svelte b/test/runtime/samples/target-shadow-dom/App.svelte new file mode 100644 index 0000000000..251e480307 --- /dev/null +++ b/test/runtime/samples/target-shadow-dom/App.svelte @@ -0,0 +1,11 @@ + + +
Hello {name}
+ + \ No newline at end of file diff --git a/test/runtime/samples/target-shadow-dom/_config.js b/test/runtime/samples/target-shadow-dom/_config.js new file mode 100644 index 0000000000..cec383afd0 --- /dev/null +++ b/test/runtime/samples/target-shadow-dom/_config.js @@ -0,0 +1,13 @@ +export default { + skip_if_ssr: true, + compileOptions: { + cssHash: () => 'svelte-xyz' + }, + async test({ assert, component, target, window }) { + assert.htmlEqual(window.document.head.innerHTML, ''); + assert.htmlEqual(component.div.shadowRoot.innerHTML, ` + +
Hello World
+ `); + } +}; diff --git a/test/runtime/samples/target-shadow-dom/main.svelte b/test/runtime/samples/target-shadow-dom/main.svelte new file mode 100644 index 0000000000..cb47ad01f0 --- /dev/null +++ b/test/runtime/samples/target-shadow-dom/main.svelte @@ -0,0 +1,19 @@ + + +
\ No newline at end of file diff --git a/test/runtime/samples/transition-css-in-out-in-with-param/_config.js b/test/runtime/samples/transition-css-in-out-in-with-param/_config.js new file mode 100644 index 0000000000..c5dfb63225 --- /dev/null +++ b/test/runtime/samples/transition-css-in-out-in-with-param/_config.js @@ -0,0 +1,21 @@ +export default { + test({ assert, component, target, window, raf }) { + component.visible = true; + const div = target.querySelector('div'); + + // animation duration of `in` should be 10ms. + assert.equal(div.style.animation, '__svelte_1670736059_0 10ms linear 0ms 1 both'); + + // animation duration of `out` should be 5ms. + component.visible = false; + assert.equal(div.style.animation, '__svelte_1670736059_0 10ms linear 0ms 1 both, __svelte_1998461463_0 5ms linear 0ms 1 both'); + + // change param + raf.tick(1); + component.param = true; + component.visible = true; + + // animation duration of `in` should be 20ms. + assert.equal(div.style.animation, '__svelte_722598827_0 20ms linear 0ms 1 both'); + } +}; diff --git a/test/runtime/samples/transition-css-in-out-in-with-param/main.svelte b/test/runtime/samples/transition-css-in-out-in-with-param/main.svelte new file mode 100644 index 0000000000..616e2e0e8b --- /dev/null +++ b/test/runtime/samples/transition-css-in-out-in-with-param/main.svelte @@ -0,0 +1,26 @@ + + +{#if visible} +
+{/if} \ No newline at end of file diff --git a/test/runtime/samples/transition-css-in-out-in/_config.js b/test/runtime/samples/transition-css-in-out-in/_config.js index cd7ae14ce8..6d93c0e8c3 100644 --- a/test/runtime/samples/transition-css-in-out-in/_config.js +++ b/test/runtime/samples/transition-css-in-out-in/_config.js @@ -15,6 +15,6 @@ export default { component.visible = true; // reset original styles - assert.equal(div.style.animation, '__svelte_3809512021_1 100ms linear 0ms 1 both'); + assert.equal(div.style.animation, '__svelte_3809512021_0 100ms linear 0ms 1 both'); } }; diff --git a/test/runtime/samples/transition-js-slot-2/_config.js b/test/runtime/samples/transition-js-slot-2/_config.js index 67cc0b46d2..0f0cad5e41 100644 --- a/test/runtime/samples/transition-js-slot-2/_config.js +++ b/test/runtime/samples/transition-js-slot-2/_config.js @@ -1,3 +1,4 @@ +// cancelled the transition halfway export default { html: `
Foo
diff --git a/test/runtime/samples/transition-js-slot-4-cancelled/Nested.svelte b/test/runtime/samples/transition-js-slot-4-cancelled/Nested.svelte new file mode 100644 index 0000000000..04eea750fd --- /dev/null +++ b/test/runtime/samples/transition-js-slot-4-cancelled/Nested.svelte @@ -0,0 +1,19 @@ + + +{#if visible} +
+ +
+{/if} \ No newline at end of file diff --git a/test/runtime/samples/transition-js-slot-4-cancelled/_config.js b/test/runtime/samples/transition-js-slot-4-cancelled/_config.js new file mode 100644 index 0000000000..d6b7c31132 --- /dev/null +++ b/test/runtime/samples/transition-js-slot-4-cancelled/_config.js @@ -0,0 +1,35 @@ +// updated props in the middle of transitions +// and cancelled the transition halfway +export default { + html: ` +
outside Foo Foo Foo
+
inside Foo Foo Foo
+ `, + props: { + props: 'Foo' + }, + + async test({ assert, component, target, window, raf }) { + await component.hide(); + const [, div] = target.querySelectorAll('div'); + + raf.tick(50); + assert.equal(div.foo, 0.5); + + component.props = 'Bar'; + assert.htmlEqual(target.innerHTML, ` +
outside Bar Bar Bar
+
inside Foo Foo Foo
+ `); + + await component.show(); + + assert.htmlEqual(target.innerHTML, ` +
outside Bar Bar Bar
+
inside Bar Bar Bar
+ `); + + raf.tick(100); + assert.equal(div.foo, 1); + } +}; diff --git a/test/runtime/samples/transition-js-slot-4-cancelled/main.svelte b/test/runtime/samples/transition-js-slot-4-cancelled/main.svelte new file mode 100644 index 0000000000..1003419244 --- /dev/null +++ b/test/runtime/samples/transition-js-slot-4-cancelled/main.svelte @@ -0,0 +1,22 @@ + + +
outside {state} {props} {slotProps}
+ + inside {state} {props} {slotProps} + diff --git a/test/runtime/samples/transition-js-slot-5-cancelled-overflow/Nested.svelte b/test/runtime/samples/transition-js-slot-5-cancelled-overflow/Nested.svelte new file mode 100644 index 0000000000..10050b6a10 --- /dev/null +++ b/test/runtime/samples/transition-js-slot-5-cancelled-overflow/Nested.svelte @@ -0,0 +1,19 @@ + + +{#if visible} +
+ +
+{/if} diff --git a/test/runtime/samples/transition-js-slot-5-cancelled-overflow/_config.js b/test/runtime/samples/transition-js-slot-5-cancelled-overflow/_config.js new file mode 100644 index 0000000000..aedc87f0b6 --- /dev/null +++ b/test/runtime/samples/transition-js-slot-5-cancelled-overflow/_config.js @@ -0,0 +1,40 @@ +// updated props in the middle of transitions +// and cancelled the transition halfway +// + spreaded props + overflow context + +export default { + html: ` +
outside Foo Foo Foo
+
inside Foo Foo Foo
+ 0 + `, + props: { + props: 'Foo' + }, + + async test({ assert, component, target, window, raf }) { + await component.hide(); + const [, div] = target.querySelectorAll('div'); + + raf.tick(50); + assert.equal(div.foo, 0.5); + + component.props = 'Bar'; + assert.htmlEqual(target.innerHTML, ` +
outside Bar Bar Bar
+
inside Foo Foo Foo
+ 0 + `); + + await component.show(); + + assert.htmlEqual(target.innerHTML, ` +
outside Bar Bar Bar
+
inside Bar Bar Bar
+ 0 + `); + + raf.tick(100); + assert.equal(div.foo, 1); + } +}; diff --git a/test/runtime/samples/transition-js-slot-5-cancelled-overflow/main.svelte b/test/runtime/samples/transition-js-slot-5-cancelled-overflow/main.svelte new file mode 100644 index 0000000000..9c46fd0521 --- /dev/null +++ b/test/runtime/samples/transition-js-slot-5-cancelled-overflow/main.svelte @@ -0,0 +1,27 @@ + + +
outside {state} {props} {slotProps}
+ + + inside {state} {props} {slotProps} + + +{a1+a2+a3+a4+a5+a6+a7+a8+a9+a10+a11+a12+a13+a14+a15+a16+a17+a18+a19+a20+a21+a22+a23+a24+a25+a26+a27+a28+a29+a30+a31+a32+a33} \ No newline at end of file diff --git a/test/runtime/samples/transition-js-slot-6-spread-cancelled/Nested.svelte b/test/runtime/samples/transition-js-slot-6-spread-cancelled/Nested.svelte new file mode 100644 index 0000000000..b1853993d3 --- /dev/null +++ b/test/runtime/samples/transition-js-slot-6-spread-cancelled/Nested.svelte @@ -0,0 +1,19 @@ + + +{#if visible} +
+ +
+{/if} \ No newline at end of file diff --git a/test/runtime/samples/transition-js-slot-6-spread-cancelled/Nested2.svelte b/test/runtime/samples/transition-js-slot-6-spread-cancelled/Nested2.svelte new file mode 100644 index 0000000000..52f89858a0 --- /dev/null +++ b/test/runtime/samples/transition-js-slot-6-spread-cancelled/Nested2.svelte @@ -0,0 +1,19 @@ + + +{#if visible} +
+ +
+{/if} \ No newline at end of file diff --git a/test/runtime/samples/transition-js-slot-6-spread-cancelled/_config.js b/test/runtime/samples/transition-js-slot-6-spread-cancelled/_config.js new file mode 100644 index 0000000000..1d42c9cf71 --- /dev/null +++ b/test/runtime/samples/transition-js-slot-6-spread-cancelled/_config.js @@ -0,0 +1,40 @@ +// updated props in the middle of transitions +// and cancelled the transition halfway +// with spreaded props + +export default { + html: ` +
outside Foo Foo Foo
+
inside Foo Foo Foo
+
inside Foo Foo XXX
+ `, + props: { + props: 'Foo' + }, + + async test({ assert, component, target, window, raf }) { + await component.hide(); + const [, div] = target.querySelectorAll('div'); + + raf.tick(50); + assert.equal(div.foo, 0.5); + + component.props = 'Bar'; + assert.htmlEqual(target.innerHTML, ` +
outside Bar Bar Bar
+
inside Foo Foo Foo
+
inside Foo Foo XXX
+ `); + + await component.show(); + + assert.htmlEqual(target.innerHTML, ` +
outside Bar Bar Bar
+
inside Bar Bar Bar
+
inside Bar Bar XXX
+ `); + + raf.tick(100); + assert.equal(div.foo, 1); + } +}; diff --git a/test/runtime/samples/transition-js-slot-6-spread-cancelled/main.svelte b/test/runtime/samples/transition-js-slot-6-spread-cancelled/main.svelte new file mode 100644 index 0000000000..5dd8ce348e --- /dev/null +++ b/test/runtime/samples/transition-js-slot-6-spread-cancelled/main.svelte @@ -0,0 +1,26 @@ + + +
outside {state} {props} {slotProps.slotProps}
+ + inside {state} {props} {slotProps} + + + inside {state} {props} {slotProps} + diff --git a/test/runtime/samples/transition-js-slot-7-spread-cancelled-overflow/Nested.svelte b/test/runtime/samples/transition-js-slot-7-spread-cancelled-overflow/Nested.svelte new file mode 100644 index 0000000000..b01200fd9f --- /dev/null +++ b/test/runtime/samples/transition-js-slot-7-spread-cancelled-overflow/Nested.svelte @@ -0,0 +1,19 @@ + + +{#if visible} +
+ +
+{/if} diff --git a/test/runtime/samples/transition-js-slot-7-spread-cancelled-overflow/_config.js b/test/runtime/samples/transition-js-slot-7-spread-cancelled-overflow/_config.js new file mode 100644 index 0000000000..aedc87f0b6 --- /dev/null +++ b/test/runtime/samples/transition-js-slot-7-spread-cancelled-overflow/_config.js @@ -0,0 +1,40 @@ +// updated props in the middle of transitions +// and cancelled the transition halfway +// + spreaded props + overflow context + +export default { + html: ` +
outside Foo Foo Foo
+
inside Foo Foo Foo
+ 0 + `, + props: { + props: 'Foo' + }, + + async test({ assert, component, target, window, raf }) { + await component.hide(); + const [, div] = target.querySelectorAll('div'); + + raf.tick(50); + assert.equal(div.foo, 0.5); + + component.props = 'Bar'; + assert.htmlEqual(target.innerHTML, ` +
outside Bar Bar Bar
+
inside Foo Foo Foo
+ 0 + `); + + await component.show(); + + assert.htmlEqual(target.innerHTML, ` +
outside Bar Bar Bar
+
inside Bar Bar Bar
+ 0 + `); + + raf.tick(100); + assert.equal(div.foo, 1); + } +}; diff --git a/test/runtime/samples/transition-js-slot-7-spread-cancelled-overflow/main.svelte b/test/runtime/samples/transition-js-slot-7-spread-cancelled-overflow/main.svelte new file mode 100644 index 0000000000..000b29ee7f --- /dev/null +++ b/test/runtime/samples/transition-js-slot-7-spread-cancelled-overflow/main.svelte @@ -0,0 +1,27 @@ + + +
outside {state} {props} {slotProps.slotProps}
+ + + inside {state} {props} {slotProps} + + +{a1+a2+a3+a4+a5+a6+a7+a8+a9+a10+a11+a12+a13+a14+a15+a16+a17+a18+a19+a20+a21+a22+a23+a24+a25+a26+a27+a28+a29+a30+a31+a32+a33} \ No newline at end of file diff --git a/test/server-side-rendering/samples/spread-attributes-white-space/_expected.html b/test/server-side-rendering/samples/spread-attributes-white-space/_expected.html index a73bb17e8c..24473a7b12 100644 --- a/test/server-side-rendering/samples/spread-attributes-white-space/_expected.html +++ b/test/server-side-rendering/samples/spread-attributes-white-space/_expected.html @@ -2,7 +2,4 @@ bar "> - \ No newline at end of file + \ No newline at end of file diff --git a/test/sourcemaps/samples/attached-sourcemap/test.js b/test/sourcemaps/samples/attached-sourcemap/test.js index c5b4d7989d..ecb88ab11d 100644 --- a/test/sourcemaps/samples/attached-sourcemap/test.js +++ b/test/sourcemaps/samples/attached-sourcemap/test.js @@ -7,8 +7,8 @@ export function test({ input, css, js }) { let out_obj, loc_output, actual, loc_input, expected; out_obj = js; - // we need the second occurence of 'done_replace_script_2' in output.js - // the first occurence is mapped back to markup '{done_replace_script_2}' + // we need the second occurrence of 'done_replace_script_2' in output.js + // the first occurrence is mapped back to markup '{done_replace_script_2}' loc_output = out_obj.locate_1('done_replace_script_2'); loc_output = out_obj.locate_1('done_replace_script_2', loc_output.character + 1); actual = out_obj.mapConsumer.originalPositionFor(loc_output); diff --git a/test/sourcemaps/samples/sourcemap-basename-without-outputname/_config.js b/test/sourcemaps/samples/sourcemap-basename-without-outputname/_config.js new file mode 100644 index 0000000000..15c346bfb9 --- /dev/null +++ b/test/sourcemaps/samples/sourcemap-basename-without-outputname/_config.js @@ -0,0 +1,33 @@ + +import {magic_string_bundle} from '../../helpers'; + +export const component_filepath = 'src/some/deep/path/input.svelte'; +export const component_file_basename = 'input.svelte'; +export const css_file_basename = 'input.css'; + +const input_css = ' h1 {color: blue;}'; + +export default { + preprocess: [ + { + style: ({ content, filename }) => { + const style_to_add = `/* Filename from preprocess: ${filename} */` + input_css; + return magic_string_bundle([ + { code: content, filename: component_file_basename }, + { code: style_to_add, filename: css_file_basename } + ],component_filepath); + } + } + ], + js_map_sources: [component_file_basename], + css_map_sources: [css_file_basename,component_file_basename], + options: { + filename: component_filepath + }, + compile_options: { + filename: component_filepath, + // ../../index.ts initializes output filenames, reset to undefined for this test + outputFilename: undefined, + cssOutputFilename: undefined + } +}; diff --git a/test/sourcemaps/samples/sourcemap-basename-without-outputname/input.svelte b/test/sourcemaps/samples/sourcemap-basename-without-outputname/input.svelte new file mode 100644 index 0000000000..189f28c390 --- /dev/null +++ b/test/sourcemaps/samples/sourcemap-basename-without-outputname/input.svelte @@ -0,0 +1,2 @@ +

sourcemap-basename-without-outputname

+ diff --git a/test/sourcemaps/samples/sourcemap-basename-without-outputname/test.js b/test/sourcemaps/samples/sourcemap-basename-without-outputname/test.js new file mode 100644 index 0000000000..c5747713a7 --- /dev/null +++ b/test/sourcemaps/samples/sourcemap-basename-without-outputname/test.js @@ -0,0 +1,3 @@ +// no additional test needed, _config.js values and the js.map.sources assertion in ../../index.ts cover it +export function test() {} + diff --git a/test/validator/samples/reactive-module-const-variable/input.svelte b/test/validator/samples/reactive-module-const-variable/input.svelte new file mode 100644 index 0000000000..c89cc1c1d0 --- /dev/null +++ b/test/validator/samples/reactive-module-const-variable/input.svelte @@ -0,0 +1,9 @@ + + + diff --git a/test/validator/samples/reactive-module-const-variable/warnings.json b/test/validator/samples/reactive-module-const-variable/warnings.json new file mode 100644 index 0000000000..0d4f101c7a --- /dev/null +++ b/test/validator/samples/reactive-module-const-variable/warnings.json @@ -0,0 +1,2 @@ +[ +]