merge with master

pull/4750/head
André Lins 6 years ago
commit 6c6c039617

@ -4,6 +4,8 @@
* Fix misaligned line numbers in source maps ([#3906](https://github.com/sveltejs/svelte/issues/3906))
* Fix reactivity with imported values that are then mutated ([#4555](https://github.com/sveltejs/svelte/issues/4555))
* Do not display a11y warning about missing `href` for `<a>` with `name` or `id` ([#4697](https://github.com/sveltejs/svelte/issues/4697))
* Disable infinite loop guard inside generators ([#4698](https://github.com/sveltejs/svelte/issues/4698))
* Display a11y warning for `href="javascript:..."` ([#4733](https://github.com/sveltejs/svelte/pull/4733))
## 3.21.0

@ -93,7 +93,7 @@ Test samples are kept in `/test/xxx/samples` folder.
#### Running tests
1. To run test, run `npm run test`
1. To run test, run `npm run test`.
1. To run test for a specific feature, you can use the `-g` (aka `--grep`) option. For example, to only run test involving transitions, run `npm run test -- -g transition`.
##### Running solo test
@ -130,7 +130,7 @@ The core Svelte team will be monitoring for pull requests. Do help us by making
### Code conventions
- `snake_case` for internal variable names and methods
- `snake_case` for internal variable names and methods.
- `camelCase` for public variable names and methods.
## License

@ -7,3 +7,5 @@ This page contains detailed API reference documentation. It's intended to be a r
If that's not you (yet), you may prefer to visit the [interactive tutorial](tutorial) or the [examples](examples) before consulting this reference.
Don't be shy about asking for help in the [Discord chatroom](chat).
Using an older version of Svelte? Have a look at the [v2 docs](https://v2.svelte.dev).

@ -206,6 +206,9 @@ Additional conditions can be added with `{:else if expression}`, optionally endi
{#each expression as name, index}...{/each}
```
```sv
{#each expression as name (key)}...{/each}
```
```sv
{#each expression as name, index (key)}...{/each}
```
```sv
@ -242,6 +245,11 @@ An each block can also specify an *index*, equivalent to the second argument in
If a *key* expression is provided — which must uniquely identify each list item — Svelte will use it to diff the list when data changes, rather than adding or removing items at the end. The key can be any object, but strings and numbers are recommended since they allow identity to persist when the objects themselves change.
```html
{#each items as item (item.id)}
<li>{item.name} x {item.qty}</li>
{/each}
<!-- or with additional index value -->
{#each items as item, i (item.id)}
<li>{i + 1}: {item.name} x {item.qty}</li>
{/each}

@ -521,7 +521,7 @@ $: $size = big ? 100 : 10;
### `svelte/transition`
The `svelte/transition` module exports six functions: `fade`, `fly`, `slide`, `scale`, `draw` and `crossfade`. They are for use with svelte [`transitions`](docs#Transitions).
The `svelte/transition` module exports six functions: `fade`, `fly`, `slide`, `scale`, `draw` and `crossfade`. They are for use with Svelte [`transitions`](docs#transition_fn).
#### `fade`
@ -758,7 +758,7 @@ The `speed` parameter is a means of setting the duration of the transition relat
### `svelte/animate`
The `svelte/animate` module exports one function for use with svelte [animations](docs#Animations).
The `svelte/animate` module exports one function for use with Svelte [animations](docs#animate_fn).
#### `flip`

@ -2,7 +2,7 @@
title: Default values
---
We can easily specify default values for props:
We can easily specify default values for props in `Nested.svelte`:
```html
<script>

@ -714,8 +714,14 @@ export default class Component {
};
let scope_updated = false;
let generator_count = 0;
walk(content, {
enter(node: Node, parent, prop, index) {
if ((node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression') && node.generator === true) {
generator_count++;
}
if (map.has(node)) {
scope = map.get(node);
}
@ -742,8 +748,12 @@ export default class Component {
},
leave(node: Node) {
if ((node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression') && node.generator === true) {
generator_count--;
}
// do it on leave, to prevent infinite loop
if (component.compile_options.dev && component.compile_options.loopGuardTimeout > 0) {
if (component.compile_options.dev && component.compile_options.loopGuardTimeout > 0 && generator_count <= 0) {
const to_replace_for_loop_protect = component.loop_protect(node, scope, component.compile_options.loopGuardTimeout);
if (to_replace_for_loop_protect) {
this.replace(to_replace_for_loop_protect);

@ -0,0 +1,6 @@
export default {
compileOptions: {
dev: true,
loopGuardTimeout: 1,
},
};

@ -0,0 +1,14 @@
<script>
const it = gen();
it.next();
setTimeout(() => {
it.next();
}, 20)
function* gen() {
while (true) {
yield;
}
}
</script>
Loading…
Cancel
Save