docs: more fixes (#13608)

pull/13612/head
Rich Harris 3 weeks ago committed by GitHub
parent 81f28ccf5d
commit caaf74b854
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -164,7 +164,7 @@ In general, `$effect` is best considered something of an escape hatch — useful
</script> </script>
``` ```
> [!NOTE] For things that are more complicated than a simple expression like `count * 2`, you can also use [`$derived.by`](#$derived-by). > [!NOTE] For things that are more complicated than a simple expression like `count * 2`, you can also use `$derived.by`.
You might be tempted to do something convoluted with effects to link one value to another. The following example shows two inputs for "money spent" and "money left" that are connected to each other. If you update one, the other should update accordingly. Don't use effects for this ([demo](/#H4sIAAAAAAAACpVRy2rDMBD8lWXJwYE0dg-9KFYg31H3oNirIJBlYa1DjPG_F8l1XEop9LgzOzP7mFAbSwHF-4ROtYQCL97jAXn0sQh3skx4wNANfR2RMtS98XyuXMWWGLhjZUHCa1GcVix4cgwSdoEVU1bsn4wl_Y1I2kS6inekNdWcZXuQZ5giFDWpfwl5WYyT2fynbB1g1UWbTVbm2w6utOpKNq1TGucHhri6rLBX7kYVwtW4RtyVHUhOyXeGVj3klLxnyJP0i8lXNJUx6en-v6A48K85kTimpi0sYj-yAo-Wlh9FcL1LY4K3ahSgLT1OC3ZTXkBxfKN2uVC6T5LjAduuMdpQg4L7geaP-RNHPuClMQIAAA==)): You might be tempted to do something convoluted with effects to link one value to another. The following example shows two inputs for "money spent" and "money left" that are connected to each other. If you update one, the other should update accordingly. Don't use effects for this ([demo](/#H4sIAAAAAAAACpVRy2rDMBD8lWXJwYE0dg-9KFYg31H3oNirIJBlYa1DjPG_F8l1XEop9LgzOzP7mFAbSwHF-4ROtYQCL97jAXn0sQh3skx4wNANfR2RMtS98XyuXMWWGLhjZUHCa1GcVix4cgwSdoEVU1bsn4wl_Y1I2kS6inekNdWcZXuQZ5giFDWpfwl5WYyT2fynbB1g1UWbTVbm2w6utOpKNq1TGucHhri6rLBX7kYVwtW4RtyVHUhOyXeGVj3klLxnyJP0i8lXNJUx6en-v6A48K85kTimpi0sYj-yAo-Wlh9FcL1LY4K3ahSgLT1OC3ZTXkBxfKN2uVC6T5LjAduuMdpQg4L7geaP-RNHPuClMQIAAA==)):
@ -289,7 +289,7 @@ In rare cases, you may need to run code _before_ the DOM updates. For this we ca
</div> </div>
``` ```
Apart from the timing, `$effect.pre` works exactly like [`$effect`](#$effect) — refer to its documentation for more info. Apart from the timing, `$effect.pre` works exactly like `$effect` — refer to its documentation for more info.
## `$effect.tracking` ## `$effect.tracking`

@ -64,7 +64,7 @@ result.head; // HTML for somewhere in this <head> tag
## `hydrate` ## `hydrate`
Like `mount`, but will reuse up any HTML rendered by Svelte's SSR output (from the [`render`](#server-render) function) inside the target and make it interactive: Like `mount`, but will reuse up any HTML rendered by Svelte's SSR output (from the [`render`](#render) function) inside the target and make it interactive:
```js ```js
// @errors: 2322 // @errors: 2322

@ -4,7 +4,7 @@ title: Custom elements
- [basically what we have today](https://svelte.dev/docs/custom-elements-api) - [basically what we have today](https://svelte.dev/docs/custom-elements-api)
Svelte components can also be compiled to custom elements (aka web components) using the `customElement: true` compiler option. You should specify a tag name for the component using the `<svelte:options>` [element](special-elements#svelte-options). Svelte components can also be compiled to custom elements (aka web components) using the `customElement: true` compiler option. You should specify a tag name for the component using the `<svelte:options>` [element](special-elements#svelte:options).
```svelte ```svelte
<svelte:options customElement="my-element" /> <svelte:options customElement="my-element" />
@ -36,7 +36,7 @@ document.body.innerHTML = `
`; `;
``` ```
Any [props](basic-markup#attributes-and-props) are exposed as properties of the DOM element (as well as being readable/writable as attributes, where possible). Any [props](basic-markup#Attributes-and-props) are exposed as properties of the DOM element (as well as being readable/writable as attributes, where possible).
```js ```js
// @noErrors // @noErrors

@ -328,7 +328,7 @@ async function process_markup(process, source) {
/** /**
* The preprocess function provides convenient hooks for arbitrarily transforming component source code. * The preprocess function provides convenient hooks for arbitrarily transforming component source code.
* For example, it can be used to convert a <style lang="sass"> block into vanilla CSS. * For example, it can be used to convert a `<style lang="sass">` block into vanilla CSS.
* *
* @param {string} source * @param {string} source
* @param {PreprocessorGroup | PreprocessorGroup[]} preprocessor * @param {PreprocessorGroup | PreprocessorGroup[]} preprocessor

@ -1247,7 +1247,7 @@ declare module 'svelte/compiler' {
| AST.SvelteWindow; | AST.SvelteWindow;
/** /**
* The preprocess function provides convenient hooks for arbitrarily transforming component source code. * The preprocess function provides convenient hooks for arbitrarily transforming component source code.
* For example, it can be used to convert a <style lang="sass"> block into vanilla CSS. * For example, it can be used to convert a `<style lang="sass">` block into vanilla CSS.
* *
* */ * */
export function preprocess(source: string, preprocessor: PreprocessorGroup | PreprocessorGroup[], options?: { export function preprocess(source: string, preprocessor: PreprocessorGroup | PreprocessorGroup[], options?: {

Loading…
Cancel
Save