0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-12-01 17:30:59 +01:00
Commit Graph

2677 Commits

Author SHA1 Message Date
Bob Fanger
0b0221de99
[fix] Local transitions from #key blocks (#7286)
* fix: Local transitions from #key blocks

When adding `|local` to a transition inside a {#key} block, only the outro was triggered not the intro.

This PR fixes #5950

* add test case

Co-authored-by: tanhauhau <lhtan93@gmail.com>
2022-04-16 09:40:53 +08:00
Yosuke Ota
3a238fe057
[fix] strip leading newline after <pre> and <textarea> (#7280)
Fixes #7264
2022-04-14 16:31:03 +02:00
Tan Li Hau
4aff59b080
[fix] correctly track dependencies of let: bindings (#7448)
Fixes #7440
2022-04-13 17:34:40 +02:00
Henning Groß
9276f85768
[feat] improve error message for animate used in a non-keyed each block (#6838)
* introdcued new compiler error

* making use of newly created compiler error

* updated test for animation not in keyed each

* removed unneeded conditions
2022-04-13 00:22:11 +08:00
Tan Li Hau
d9687da632
each animate allow having comment siblings (#7435)
Co-authored-by: GHOST <ghostdevbusiness@gmail.com>

Co-authored-by: GHOST <ghostdevbusiness@gmail.com>
2022-04-12 16:48:09 +08:00
Tan Li Hau
e50be669cc
fix const declared without let: binding get ignored (#7434) 2022-04-12 16:38:08 +08:00
gtmnayan
afd3f4e5a9
[feat] Make setContext return the value that was passed in (#7432)
* return value from setContext

* update docs

* Add test

* eof new line

* pacify the linter

* const and tabs
2022-04-11 08:50:28 +08:00
Yuichiro Yamashita
eca1a652fb
[fix] better context checks for identifiers in const tags (#7222)
Fixes #7423
Fixes #7431
Fixes #7206
Fixes #7431
Fixes #7221

Co-authored-by: tanhauhau <lhtan93@gmail.com>
2022-04-08 19:30:49 +02:00
Yuichiro Yamashita
e0d93254fd
[feature] Dynamic elements implementation <svelte:element> (#6898)
Closes #2324

Co-authored-by: Alfred Ringstad <alfred.ringstad@hyperlab.se>
Co-authored-by: Simon Holthausen <simon.holthausen@accso.de>
Co-authored-by: tanhauhau <lhtan93@gmail.com>
2022-04-08 16:54:55 +02:00
Tan Li Hau
89fda7edae
[fix] add key dependencies into block dependencies (#7422)
* add key dependencies into block dependencies

* fix lint
2022-04-08 22:24:15 +08:00
Pat Cavit
9f4602ac6f
[fix] style: directive should prevent innerHTML optimization (#7390)
Fixes #7386
2022-03-30 10:49:25 -04:00
Maurício Kishi
cdd3575026
[fix] attribute escaping during ssr (#7333)
Fixes #7327 and a related security issue
2022-03-03 12:22:38 +01:00
Geoff Rich
0a3353b671
[fix] do not collapse whitespace-only css vars (#7303)
Fixes #7152, see also #7288

--foo:; used to be an invalid CSS custom property value, while -foo: ; was valid. By collapsing the whitespace in these declaration values, we were breaking scenarios where an empty custom property was desired. The spec was updated to trim whitespace and treat these values identically, but Chromium browsers still treat --foo; as invalid. This was recently fixed and will be released in Chrome 99, but this would still be a good fix to maintain backwards compatibility.
2022-03-03 08:25:52 +01:00
rgossiaux
e2adf6a211
fix: do not generate unused-export-let inside <script context="module"> (#7232)
Fixes #7055. This warning can be delegated to userland tools like eslint
2022-03-02 16:55:02 -08:00
Yosuke Ota
7463d51301
[fix]: keep space in <pre> or when preserveWhitespace: true (#6990)
Fixes #6437
Fixes #4731
Closes #4737

Whitespace is now untouched inside <pre> tag and other tags if preserveWhitespace is true
2022-02-02 09:30:25 +01:00
Efe Selim Küçük
587f94eb65
[feat] Better error message for inline component style directive (#7187)
Closes #7177
2022-02-02 08:56:23 +01:00
Yuichiro Yamashita
5665f711fd
[fix] raise compile error if variable name is same as imported variable name (#7145) 2022-01-26 10:16:20 -05:00
Yuichiro Yamashita
00e394e3c8
[fix] fix crash when using arrow functions in {@const} (#7144) 2022-01-26 09:50:18 -05:00
Andreas Ehrencrona
a4e4027f79
Handle whitespace inside #each with animation (#5477)
* Strip out whitespace inside each when it has an animation

* remove accidentally committed file

* lint

* add test to validate no error

* update changelog

Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
Co-authored-by: tanhauhau <lhtan93@gmail.com>
Co-authored-by: Tan Li Hau <tanhauhau@users.noreply.github.com>
2022-01-15 11:47:02 +08:00
Tan Li Hau
dc06ea916e
fix: style directive not reactive in {#each} loop (#7140) 2022-01-14 12:16:34 -05:00
Tan Li Hau
815bc7ef6e
fix: test cases should fail when it should fail (#7139) 2022-01-14 12:12:23 -05:00
Simon H
7044a32a2b
[fix] adjust style directive AST (#7127)
- deduplicate type name: Is now "StyleDirective"
- Don't transform value array to template literal in the AST phase but in the compiler phase. This ensures other tools know what the raw output was and that start/end positions are available
2022-01-12 15:12:50 -05:00
GHOST
c67f8ef14c
[fix] handle kebab case style directives (#7123)
fixes #7122
2022-01-12 11:42:13 +01:00
Tan Li Hau
b5aaa6641b
[feat] implement constants in markup (#6413) 2022-01-11 17:10:09 -05:00
Yuichiro Yamashita
895b4c6721
[fix] hydrate correct elements when using @html (#6946) 2022-01-09 06:12:57 -08:00
Paul Murray
8a47b5ec9e
[feat] Style directives (#5923)
* add Style node, interfaces

* style-directives: add parser and runtime test

* style-directives: push styles in to styles array on Element

* style-directives: minimal ssr work

* style-directives: ssr add_styles

* style-directive: tests

* style-directives: work in progress

* obviously incorrect hard-coded color

* tweak

* style directive interface

* style-directives: get text from info in Style node

* style-directives: add_styles func in ElementWrapper

* style-directives: ssr rendering

* handle text-only style directive in tag.ts

* style-directives: handle spread styles in ssr

* style-directives: more parser tests

* style-directives: more inline tests

* style-directives: remove solo tests

* style-directives: cleanup

* style-directives: tweak spread ssr internal

* style-directives: push updater into update chunks; add dynamic test;

* remove .solo

* check for dynamic dependencies before adding update chunk

* add test of multiple styles; remove null styles;

* style-directives: docs; more tests of multiple styles

* style-directives: use camelcase

* style-directives: cleanup

* style-directives: fix mustache template case with template literal

* style-directives: use ternary

* style-directives: linting

* style-directives: remove "text" from interface

* style-directives: actually, remove StyleDirective interface entriely

* add more test, fix test for ssr

* fix lint and tidy up

* add test for css variables

* fix linting errors

Co-authored-by: pmurray73 <pmurray73@bloomberg.net>
Co-authored-by: Tan Li Hau <lhtan93@gmail.com>
2022-01-08 11:09:11 -05:00
Tan Li Hau
5e40277167
[feat] add reference for default values in destructuring context (#7007) 2022-01-06 16:05:49 -05:00
Tan Li Hau
9f2b5afdf7
[fix] binding member expression should only invalidate the object, not the member property (#7008) 2022-01-06 15:28:53 -05:00
Tan Li Hau
2f0f330b76
[fix] {:else if} value incorrectly cached (#7043) 2022-01-06 11:07:37 -05:00
pngwn
4240455e02
[fix] ensure truthy non-boolean attributes are rendered correctly in SSR (#7066) 2022-01-06 10:14:09 -05:00
Yuichiro Yamashita
966c03a317
[chore] fix test flakiness (#7076) 2022-01-05 10:30:02 -08:00
Ignatius Bagus
2012124e87
[fix] foreign namespace hash link (#7080) 2022-01-04 13:41:42 -08:00
James Bradbury
84a4ef07c9
[feat] add a11y-no-redundant-roles check (#7067)
Part of #820
Closes #5361

Co-authored-by: mhatvan <markus_hatvan@aon.at>
2022-01-03 11:33:08 +01:00
Bassam Ismail
c663104937
[fix] prevent cursor jump for all text inputs (#6941) 2021-12-13 14:30:53 -05:00
Tan Li Hau
6ecc3e4d6a
[feat] opt-out loopGuard for async loops (#6963) 2021-12-13 10:32:33 -05:00
Robin Munn
5a8851436f
[fix] bind:this during onMount in manually-created component (#6920) 2021-12-13 10:02:10 -05:00
Aykut Kardaş
2c8e77bf90
[refactor] refactor trim utils and write tests (#6909) 2021-11-09 07:53:49 -05:00
Bjorn Lu
be1eff0305
[feat] add enableSourcemap option (#6835) 2021-10-17 13:04:35 -04:00
Vaibhav Rai
b6b7f5c8a4
[fix] properly respect sveltePath when rewriting user imports (#6842) 2021-10-12 16:13:44 -04:00
Yuichiro Yamashita
a5968dd2d0
[chore] adjust @typescript-eslint/no-unused-vars lint config (#6798) 2021-10-07 16:41:28 -04:00
Conduitry
10ce5c95fd
[fix] handle promise rejections for {#await} in SSR (#6790) 2021-09-30 08:21:32 -04:00
Conduitry
67b53bfe6d
[fix] prefer context from constructor options (#6759) 2021-09-22 16:39:03 -04:00
Bjorn Lu
b845307698
[fix] handle preprocess with empty sourcemaps (#6757) 2021-09-22 13:21:40 -04:00
Bjorn Lu
79df74b087
[fix] run else-if reactive function on re-renders (#6727) 2021-09-15 16:23:41 -04:00
Shinobu Hayashi
f1f7d90240
[fix] handle AssignmentPattern with ObjectPattern in rewrite_identifier (#6715) 2021-09-10 11:36:40 -04:00
Conduitry
6735d5422c [chore] fix js sample test 2021-08-27 15:16:27 -04:00
Yuichiro Yamashita
fc4797c6f8
[fix] only use optimized 'src' handling for 'html' namespace (#6580) 2021-08-27 15:08:38 -04:00
Shinobu Hayashi
fc9241fea9
[fix] handle undefined select value with spread (#6687) 2021-08-27 14:53:18 -04:00
Theodore Brown
8cb72d9716
[fix] set selectedIndex to -1 when no option matches bound <select> value (#6170) 2021-08-20 12:24:49 -04:00
tomoam
907223cc78
[fix] only rely on element/svg_element functions if a hydrating component needs them (#6556) 2021-08-20 12:20:00 -04:00
Tan Li Hau
f25a995f7b
collapse whitespace in class and style attributes (#6613) 2021-08-20 12:05:58 -04:00
Tommy Groshong
a232d68a41
docs: small spelling fixes in docs and comments (#6653) 2021-08-15 13:27:43 -07:00
Hasan Altan Birler
100561c336
[fix] hydration append issue (#6602) 2021-08-04 14:16:29 -04:00
Tan Li Hau
ce550adef6
[feat] allow use:actions on <svelte:body> (#6608) 2021-08-04 12:19:13 -04:00
Tan Li Hau
64b882e3c5
[feat] improve parser errors (#6612) 2021-08-04 12:03:34 -04:00
Oliver Ford
f48239914d
[fix] warning on reactive use of module const (#6606) (#6607) 2021-08-03 18:10:56 -04:00
Dominik G
e94d1f50bc
[fix] use consistent relative source filename for js sourcemaps (#6598) 2021-08-03 18:03:36 -04:00
Tan Li Hau
e1d0d00ebb
[feat] allow shorthand {#await ... then/catch} (#6564) 2021-07-27 09:58:32 -04:00
Tan Li Hau
b720f0e620
[feat] support destructured declaration of props (#6578) 2021-07-27 09:53:55 -04:00
Tan Li Hau
c550f604f2
[feat] enable export ... from (#6574) 2021-07-27 09:37:37 -04:00
Tan Li Hau
d75ed6a003
[fix] slot data for cancelled transition (#6314) 2021-07-26 14:03:35 -04:00
Yuichiro Yamashita
c8732c8a27
[fix] create in transition even if intro is initialized (#6516) 2021-07-26 13:56:38 -04:00
Tan Li Hau
9501ac6257
[fix] destructuring store assignment (#6529) 2021-07-26 13:44:15 -04:00
Tan Li Hau
ee769101fc
[fix] applying :global for > combinator (#6563) 2021-07-26 13:42:10 -04:00
Tan Li Hau
1952ea22de
[fix] no root node for detached dom node (#6570) 2021-07-26 13:35:12 -04:00
Yuichiro Yamashita
fd8c5885c8
[fix] create AST node of empty string for empty attribute values (#6539)
Co-authored-by: Conduitry <git@chor.date>
2021-07-23 14:57:47 -04:00
Bjorn Lu
71c29bbf35
[fix] dynamic autofocus (#6494) 2021-07-23 14:18:16 -04:00
Simon H
4ca2af41df
[fix] add filename to combined source map if needed (#6089) 2021-07-23 09:44:26 -07:00
Tan Li Hau
b23d267f1f
[fix] improper :global() style encapsulation (#6560) 2021-07-22 12:53:45 -04:00
Tan Li Hau
365b5e300c
[fix] store reactivity in reactive declarations (#6559) 2021-07-22 10:59:11 -04:00
Tan Li Hau
8c66acfa92
fix one-way <select> bind with spread (#6512) 2021-07-21 16:36:16 -04:00
Tan Li Hau
c54d57b0d9
don't scope :root selector (#6514) 2021-07-21 16:33:49 -04:00
Tan Li Hau
f906180435
fix binding when updating through accessors (#6523) 2021-07-21 16:25:18 -04:00
Tan Li Hau
ef14280e28
use simpler insert and append functions when not compiling with hydration (#6525) 2021-07-21 16:21:06 -04:00
Yuichiro Yamashita
d9da22ac04
fix AST .end index for expressions in attributes (#6542) 2021-07-21 15:54:47 -04:00
Hofer Ivan
5cfefeb6e7
support rendering components in a shadow dom (#5870) 2021-07-21 15:51:31 -04:00
Hasan Altan Birler
ecbd96af95
[fix] hydration improvements (#6449) 2021-07-21 12:28:44 -04:00
Tan Li Hau
cb189ad0ec
[chore] update code-red, estree-walker, is-reference (#6551)
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
2021-07-20 22:33:02 -07:00
Tan Li Hau
222a9dd2c6
[feat] get all contexts (#6528)
* get all contexts

* docs

* explicit return type

* allow specifying return type through generic parameter

* Update site/content/docs/03-run-time.md

Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
2021-07-21 12:59:00 +08:00
Maxime LUCE
0cf5511ae0
[feat] Add errorMode option to compile to allow continuing on errors (and mark them as warnings) (#6194)
This PR adds a new option errorMode to CompileOptions to allow continuing the compilation process when errors occured.
When set to warn, this new option will indicate to Svelte that it should log errors as warnings and continue compilation.

This allows (notably) preprocessors to compile the markup to detect vars in markup before preprocessing (in this case: script and style tags are stripped so it can produce a lot of errors).

This PR is part of a work on the svelte-preprocess side to improve the preprocessing of TypeScript files: https://github.com/sveltejs/svelte-preprocess/issues/318

- allow compiler to pass error as warnings
- enforce stops after errors during compilation (for type-checking, TS doesn't know the error method throws)
- should review Element.ts:302
- added a test case for errorMode
- added documentation
2021-07-17 13:37:29 +02:00
Tan Li Hau
fd031105aa
[fix] do not warn if module variables are not the only dependencies in reactive statements (#6510)
The warning was too strict, since there are valid use cases for having non-reactive variables inside reactive statements
Fixes #5954
2021-07-14 10:01:05 +02:00
Simon H
a8c35daa9a
[fix] be able to silence more warnings (#6504)
including css-unused-selector, unused-export-let, module-script-reactive-declaration
Fixes #5954
Related to #5281
2021-07-14 09:54:15 +02:00
Tan Li Hau
2818567925
fix input value 0 for ssr (#6458) 2021-07-13 17:02:43 -07:00
Tan Li Hau
23f8f4ba6d
[feat] centralise parse errors (#6519)
Co-authored-by: pngwn <hello@pngwn.io>
2021-07-13 19:33:55 +02:00
Tan Li Hau
6a582af839
[fix] script style end parsing (#6511)
* update script end tag parsing to allow whitespace after tagname

* update style end tag parsing to allow for whitespace after tag name

* handle no closing match for script and style for eof and non-eof failures

* cleaning up script and style end tag parsing

Co-authored-by: pngwn <hello@pngwn.io>
2021-07-12 22:57:27 +08:00
Tan Li Hau
ebaa891e69
[chore] update code-red@0.2.0 (#6425)
Co-authored-by: Conduitry <git@chor.date>
2021-07-10 06:15:44 -07:00
Tan Li Hau
2cec6a94bc
[feat] sourcemap markup (#6427)
* sourcemap markup

* sourcemap textnode

* update test
2021-07-10 12:12:44 +08:00
Jonnie
7bcbe67939
add ssr for group bindings (#4621)
* add ssr for group bindings

* remove unnecessary chunk length check

* check if checkbox or radio

Co-authored-by: tanhauhau <lhtan93@gmail.com>
2021-07-10 12:07:37 +08:00
Tan Li Hau
f60cb22a9d
standalone :global() with multiple selectors shouldn't be treated as error (#6508) 2021-07-08 11:24:22 -04:00
Daybrush (Younkue Choi)
201a71d8b7
fix insert function (#6445) 2021-07-08 05:39:53 -07:00
Geoff Rich
391258aa10
Remove caption warning on <audio> (#6054) 2021-07-02 12:02:02 -07:00
Geoff Rich
e73f641ca5
Remove deprecated a11y-no-onchange warning (#6457) 2021-06-29 10:46:03 -04:00
Tan Li Hau
fca6a6d38a
:global() with pseudo element should be considered as global (#6470) 2021-06-29 10:45:29 -04:00
Tan Li Hau
98ddf8b588
update periscopic (#6471) 2021-06-29 10:44:54 -04:00
Ignatius Bagus
8c3fb922d8
only check selector that are direct children of :global (#6435)
* failing test for i6434

* use string match to simplify regexp

* more tests

* separate test suite

* test for commas inside attributes

* stricter regex pattern

* test escaped brackets and parentheses

* change latest test selector to lists

* correct failing test for escaped parentheses

* update with proposed pattern
2021-06-29 15:08:58 +08:00
Maxime LUCE
aedf69c1cf
Add compilation variables report option to allow getting all variables (even undeclared or internal) (#6192)
* feat: add compilation variables report option

* test: add full var report test

* docs: document varsReport compile option
2021-06-29 09:43:52 +08:00
Luis Confraria
554d5dd391
Fix preserveComments on ssr (#4736)
Fixes #4730

Co-authored-by: tanhauhau <lhtan93@gmail.com>
2021-06-28 12:56:12 +02:00
Anthony Le Goas
58790a9281
a11y: check if mouse events are accompanied by key events (#5938) 2021-06-28 12:50:52 +02:00
Mohammed Al-Qurafi
1b33248ead
#6299 - Throw a compile error when passing an empty directive name (#6300)
* Compile error when passing empty directive names

* Revert "Compile error when passing empty directive names"

This reverts commit ac8718b3a4.

* Compile error when passing empty directive names

* Adjust empty-directive-name error offset
2021-06-28 18:13:02 +08:00
zerdox
0df9233fb1
Fix wrong "slot" property warning (runtime) (#6065)
* updated: condition for warning about unknown prop

* test are updated
2021-06-28 14:45:22 +08:00