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

17 Commits

Author SHA1 Message Date
Yuichiro Yamashita
b6a400a549
chore: add prettier (#8543) 2023-05-08 23:32:52 +02:00
Simon Holthausen
418f4c2381 Merge branch 'master' into version-4 2023-05-05 17:13:45 +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
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
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
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
0700abe41d
fix: typings for svelte:document 2023-03-20 14:12:19 +01:00
Dave Lunny
f56fe33931
feat: bind:innerText for contenteditable (#4291)
closes #3311

---------

Co-authored-by: Simon Holthausen <simon.holthausen@vercel.com>
2023-03-16 10:58:49 +01:00
Simon H
11af850924
fix: correct meta attributes
fixes https://github.com/sveltejs/language-tools/issues/1917
2023-03-06 09:41:38 +01:00
Simon H
6476e9b34f
fix: add visibility event to types 2023-03-02 16:57:36 +01:00
Brad Dougherty
dd371f58fe
feat: add readyState binding for media elements (#6843)
Closes #6666

---------

Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
2023-03-01 11:54:00 +01:00
Simon H
dc36d0c9af
fix: typings for naturalWidth/Height bindings
follow-up to #7857
2023-02-28 22:42:59 +01:00
Andrew Walker
b0fed256f7
feat: Add -replacestate/-keepfocus to SvelteKit anchor tag props (#8281) 2023-02-21 11:23:13 +01:00
Chris Reade
7e6acbece3
[fix] Adding part HTML attribute to typings (#8182)
fixes #8181
2023-01-10 09:36:51 +01:00
Simon H
c73b9a00ea
[fix] add submitter property to submit event 2022-12-22 13:08:06 +01:00
Simon H
512eda7a84
[feat] add html typings (#7649)
This adds typings for HTML elements and their attributes. It's supposed to be used by the new transformation in language-tools.

Co-authored-by: Ignatius Bagus <ignatius.mbs@gmail.com>
Co-authored-by: Lyu, Wei-Da <36730922+jasonlyu123@users.noreply.github.com>
2022-12-11 21:45:11 +01:00