0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-11-29 16:36:44 +01:00
Commit Graph

7169 Commits

Author SHA1 Message Date
Simon H
e45a1e05a3
note of restructuring 2023-05-02 12:47:03 +02:00
Simon H
d083f8a3f2
feat: custom elements rework (#8457)
This is an overhaul of custom elements in Svelte. Instead of compiling to a custom element class, the Svelte component class is mostly preserved as-is. Instead a wrapper is introduced which wraps a Svelte component constructor and returns a HTML element constructor. This has a couple of advantages:

- component can be used both as a custom element as well as a regular component. This allows creating one wrapper custom element and using regular Svelte components inside. Fixes #3594, fixes #3128, fixes #4274, fixes #5486, fixes #3422, fixes #2969, helps with https://github.com/sveltejs/kit/issues/4502
- all components are compiled with injected styles (inlined through Javascript), fixes #4274
- the wrapper instantiates the component in `connectedCallback` and disconnects it in `disconnectedCallback` (but only after one tick, because this could be a element move). Mount/destroy works as expected inside, fixes #5989, fixes #8191
- the wrapper forwards `addEventListener` calls to `component.$on`, which allows to listen to custom events, fixes #3119, closes #4142 
- some things are hard to auto-configure, like attribute hyphen preferences or whether or not setting a property should reflect back to the attribute. This is why `<svelte:options customElement={..}>` can also take an object to modify such aspects. This option allows to specify whether setting a prop should be reflected back to the attribute (default `false`), what to use when converting the property to the attribute value and vice versa (through `type`, default `String`, or when `export let prop = false` then `Boolean`), and what the corresponding attribute for the property is (`attribute`, default lowercased prop name). These options are heavily inspired by lit: https://lit.dev/docs/components/properties. Closes #7638, fixes #5705
- adds a `shadowdom` option to control whether or not encapsulate the custom element. Closes #4330, closes #1748 

Breaking changes:
- Wrapped Svelte component now stays as a regular Svelte component (invokeing it like before with `new Component({ target: ..})` won't create a custom element). Its custom element constructor is now a static property named `element` on the class (`Component.element`) and should be regularly invoked through setting it in the html.
- The timing of mount/destroy/update is different. Mount/destroy/updating a prop all happen after a tick, so `shadowRoot.innerHTML` won't immediately reflect the change (Lit does this too). If you rely on it, you need to await a promise
2023-05-02 12:39:23 +02:00
Cas
c4261abfde
feat: document fullscreenElement and visibilityState bindings (#8507) 2023-04-28 10:15:58 +02:00
abirtley
a74caf1381
docs: Clarify when bind:group does not work (#8540)
Clarify documentation around when bind:group does and does not work. See issue #2308
2023-04-27 16:34:23 +02:00
xxkl1
b7359c8361
feat: add window bind devicePixelRatio support (#8534)
closes: #8285

add window bind devicePixelRatio support, change devicePixelRatio on window resize.

---------

Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
2023-04-27 16:17:42 +02:00
Yuichiro Yamashita
0677d89fff
chore: fix CI on Node 20 (#8528) 2023-04-26 14:02:22 -07:00
Yuichiro Yamashita
384927dbf3
chore: TypeScript to JavaScript + JSDoc for tests (#8526) 2023-04-26 09:24:33 +02:00
Ben McCann
8ffd2112bc
chore: fix CI setup for unit tests (#8530) 2023-04-26 09:21:21 +02:00
Nguyen Tran
f064c39d5f
fix: relax no-redundant-roles implementation (#8536)
Deals with the no-redundant-roles part of #8529

There was an erroneous check which compares the element name with the current role. This fix brings no-redundant-roles closer to the original eslint-jsx implementation
2023-04-26 09:18:22 +02:00
Simon H
572f5372d4
breaking: deprecate SvelteComponentTyped, add generics to SvelteComponent (#8512)
Also add data- attribute to HTMLAttributes and use available TS interfaces
2023-04-24 22:03:33 +02:00
Tan Li Hau
df2f656557
feat: improve hydration, claim static html elements using innerHTML instead of deopt to claiming every nodes (#7426)
Related: #7341, #7226

For purely static HTML, instead of walking the node tree and claiming every node/text etc, hydration now uses the same innerHTML optimization technique for hydration compared to normal create. It uses a new data-svelte-h attribute which is added upon server side rendering containing a hash (computed at build time), and then comparing that hash in the client to ensure it's the same node. If the hash is the same, the whole child content is expected to be the same. If the hash is different, the whole child content is replaced with innerHTML.

---------

Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Co-authored-by: Simon Holthausen <simon.holthausen@vercel.com>
2023-04-20 09:47:38 +02:00
Simon H
6ba2f72251
chore: Update CHANGELOG.md 2023-04-19 15:27:42 +02:00
xxkl1
32153e318d
fix: inline style value become undefined (#8517)
fixes #8462

---------

Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
2023-04-19 15:21:24 +02:00
Ben McCann
6f8cdf3b0f
chore: run CI tests on Node 20 (#8519) 2023-04-19 10:23:14 +02:00
Ben McCann
d64e86a260
chore: switch from npm to pnpm (#8514) 2023-04-18 18:18:00 +02:00
Ben McCann
be645202d6
breaking: remove legacy package.json files (#8515) 2023-04-18 17:40:43 +02:00
Simon H
6bbae502f6
chore: Update CHANGELOG.md 2023-04-18 17:29:59 +02:00
gtmnayan
1964535adf
fix: interpolated style directive updates properly with spread (#8505)
fixes #8438
2023-04-18 17:27:43 +02:00
Rafi Strauss
f30faa702d
feat: improve duplicate key error for keyed each blocks (#8411)
Closes #8410

---------

Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
2023-04-18 17:18:21 +02:00
James Scott-Brown
1770fc140a
docs: clarify statement about initial values for props (#8477) 2023-04-18 16:27:04 +02:00
Chris Kerr
236ffa833d breaking: update onMount type definition to prevent async function return (#8136)
---------

Co-authored-by: Yuichiro Yamashita <xydybaseball@gmail.com>
Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
2023-04-18 11:12:34 +02:00
gtmnayan
2f423475f7 chore: produce single bundle for runtime with multiple entrypoints (#8504)
* single runtime bundle

* formatting

* dedupe output options

* fix tests apparently

* skip writeBundle for cjs build

* revert quotes

* remove manualChunks

* some node16 module resolution compliance

* disable minifyInternalExports (doesn't really make sense for a library since users'
build step will do it again anyway)
2023-04-18 11:12:33 +02:00
Yuichiro Yamashita
5d4f3bd9e5 chore: remove Node 8 and 10 logic (#8503) 2023-04-18 11:12:33 +02:00
Nguyen Tran
68bf3e8143 feat: add a11y no-noninteractive-element-interactions (#8391)
#820
2023-04-18 11:12:33 +02:00
Theodore Brown
1728a8940e fix: bind null option and input values consistently (#8328)
Null and undefined `value` bindings should always be set to an empty string. This allows native browser validation of `required` fields to work as expected with placeholder options.

Placeholder options bound to null are necessary in forms where the field is conditionally required, and the bound value is posted to an API endpoint which requires it to be a nullable number or object rather than a string.

fixes #8312
2023-04-18 11:12:33 +02:00
Tim McCabe
d587175852 feat: add a11y-no-static-element-interactions compiler rule (#8251)
Ref: #820
2023-04-18 11:12:33 +02:00
Tan Li Hau
c81522f992 breaking: conditional ActionReturn type if Parameter is void (#7442)
---------

Co-authored-by: Ivan Hofer <ivan.hofer@outlook.com>
Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
Co-authored-by: Ignatius Bagus <ignatius.mbs@gmail.com>
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Co-authored-by: Simon Holthausen <simon.holthausen@vercel.com>
2023-04-18 11:12:33 +02:00
Hofer Ivan
8e51b51dfc breaking: improve types for createEventDispatcher (#7224)
---------

Co-authored-by: Simon Holthausen <simon.holthausen@vercel.com>
2023-04-18 11:12:33 +02:00
Ben McCann
caef440391 chore: run fewer CI jobs (#8496) 2023-04-18 11:12:33 +02:00
Ben McCann
2813814396 chore: upgrade rollup (#8491)
bump to rollup 3. Includes reworking the "treat those imports as external" a bit so that Rollup builds correctly but doesn't bundle some of the (now relative) imports

---------

Co-authored-by: Simon Holthausen <simon.holthausen@vercel.com>
2023-04-18 11:12:33 +02:00
Ben McCann
99b6a25d9d chore: Svelte 4 dependency upgrades (#8486) 2023-04-18 11:12:32 +02:00
Ben McCann
d7cffa6840 chore: upgrade to TypeScript 5 (#8488)
- upgrade to TypeScript 5
- upgrade @ampproject/remapping
- remove obsolete workarounds

---------

Co-authored-by: Simon Holthausen <simon.holthausen@vercel.com>
2023-04-18 11:12:32 +02:00
Ben McCann
42362692b5 chore: bump engines field (#8489) 2023-04-18 11:12:03 +02:00
Ben McCann
932cb66a36 chore: simplify Svelte 4 CI (#8487) 2023-04-18 11:12:03 +02:00
Simon H
f0cdf77e15 chore: remove node<14 tests (#8482)
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
2023-04-18 11:12:03 +02:00
Pat Cavit
54bb1f42ee breaking: send in/out to transition fn (#8318)
Instead of "both", which doesn't make sense at that point.
2023-04-18 11:12:03 +02:00
xxkl1
b95ae0ef3c fix: html space entities lost in component slot (#8464)
fixes #8359
2023-04-18 11:12:03 +02:00
gtmnayan
6e1674e249
docs: fix type signature for StartStopNotifier (#8509)
It used the Subscriber type to represent the set callback and the
Unsubscriber to represent the cleanup callback. But the names made
it confusing what it was for.
2023-04-18 11:03:39 +02:00
gtmnayan
2cc299185f
fix: ensure version is typed as string instead of the literal __VERSION__ (#8502)
fixes #8498
2023-04-18 11:03:23 +02:00
Simon H
9425f18e52
fix: observer PR cleanup (#8484)
leftovers from #8022
2023-04-11 20:14:56 +02:00
James Scott-Brown
cd690e025b
docs: clarify meaning of "this" in a comment (#8478) 2023-04-11 14:05:22 +02:00
Simon H
56351a3fab
chore: update changelog 2023-04-11 12:19:30 +02:00
Cymaera
0adc09da97
feat: add support for resize observer bindings (#8022)
Implements ResizeObserver bindings: #5524 (comment)
Continuation of: #5963
Related to #7583

---------

Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
2023-04-11 12:17:58 +02:00
Simon H
3a7685fef5
fix: special-case width/height attribute during spread (#8412)
fixes #6752

---------

Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Co-authored-by: Tan Li Hau <tanhauhau@users.noreply.github.com>
2023-04-11 11:44:19 +02:00
Ben McCann
def1890f4f
chore: bump @jridgewell/sourcemap-codec (#8458) 2023-04-11 11:25:53 +02:00
Michael Leahy
d42ca041dd
Closes #5876. Adds single value function support to media queries and media query range syntax / MQ level 4 support. (#8430) 2023-03-30 23:48:10 +02:00
Conduitry
cfe26d8d6c -> v3.58.0 2023-03-30 13:04:33 -04:00
Conduitry
5d0e049a94 update changelog 2023-03-30 13:04:01 -04:00
Yuichiro Yamashita
5a934e9f43
fix: escape <textarea value={...}> attribute properly (#8434) 2023-03-30 13:03:00 -04:00
Conduitry
3806977678 update changelog 2023-03-30 13:02:43 -04:00