AmazonScience/SWE-PolyBench huggingface dataset:
Repository: sveltejs/svelte (JavaScript)
Date: 2019-01-05 03:58:35+00:00
Task type: Bug Fix

Issue:
if inside an await block mounts to an undefined element
Happy new year! Here's another bug I've run into on the latest v3 alpha. I'm not sure whether this is also present in v2.x.

For the code below, the compiler generates code that doesn't mount the `if_block` properly when the condition changes. Here is a full example in the [REPL](https://v3.svelte.technology/repl?version=3.0.0-alpha13&gist=4deb4bbb73e89fd8b74612852ab06d81).

```html
  {#await p1}
    <p>...</p>
  {:then name}
    {#if show}
    <h1>Hello {name}</h1>
    {/if}
  {:catch err}
    <p>{err}</p>
  {/await}
```

Looking at the generated code, the `div` passed to `if_block.m(div, if_anchor)` is undefined. 

```js
// snippet from create_then_block
p(changed, ctx) {
  if (ctx.show) {
    if (if_block) {
     if_block.p(changed, ctx);
    } else {
      if_block = create_if_block(component, ctx);
      if_block.c();
      if_block.m(div, if_block_anchor);
    }
  } else if (if_block) {
    if_block.d(1);
    if_block = null;
  }
},
```

Wrapping the if block in an actual `<div>` does make things work as expected.


Issue discussion:

Solution patch:
diff --git a/src/compile/render-dom/wrappers/AwaitBlock.ts b/src/compile/render-dom/wrappers/AwaitBlock.ts
--- a/src/compile/render-dom/wrappers/AwaitBlock.ts
+++ b/src/compile/render-dom/wrappers/AwaitBlock.ts
@@ -80,7 +80,7 @@ export default class AwaitBlockWrapper extends Wrapper {
 				status,
 				renderer,
 				block,
-				parent,
+				this,
 				child,
 				stripWhitespace,
 				nextSibling


Test patch:
diff --git a/test/runtime/samples/await-containing-if/_config.js b/test/runtime/samples/await-containing-if/_config.js
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/await-containing-if/_config.js
@@ -0,0 +1,35 @@
+let fulfil;
+
+let thePromise = new Promise(f => {
+	fulfil = f;
+});
+
+export default {
+	props: {
+		thePromise,
+		show: true
+	},
+
+	html: `
+		<div><p>loading...</p></div>
+	`,
+
+	test({ assert, component, target }) {
+		fulfil(42);
+
+		return thePromise
+			.then(() => {
+				assert.htmlEqual(target.innerHTML, `
+					<div><p>the value is 42</p></div>
+				`);
+
+				component.show = false;
+				assert.htmlEqual(target.innerHTML, `<div></div>`);
+
+				component.show = true;
+				assert.htmlEqual(target.innerHTML, `
+					<div><p>the value is 42</p></div>
+				`);
+			});
+	}
+};
\ No newline at end of file
diff --git a/test/runtime/samples/await-containing-if/main.html b/test/runtime/samples/await-containing-if/main.html
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/await-containing-if/main.html
@@ -0,0 +1,11 @@
+<div>
+	{#await thePromise}
+		<p>loading...</p>
+	{:then theValue}
+		{#if show}
+			<p>the value is {theValue}</p>
+		{/if}
+	{:catch theError}
+		<p>oh no! {theError.message}</p>
+	{/await}
+</div>
\ No newline at end of file
Repository: sveltejs/svelte (JavaScript)
Date: 2019-01-05 17:26:12+00:00
Task type: Bug Fix

Issue:
No attribute value rendered as "true"
I'd like to render an element attribute with an optional value. For example,
```html
<div no-value></div>
```

However, svelte is rendering this with the value of "true",
```html
<div no-value="true"></div>
```

If I add an empty string value, the rendering is as expected. This,
```html
<div no-value=""></div>
```
renders as,
```html
<div no-value></div>
```

I think the underlying call to `setAttribute()` should be a blank string if there is no value instead of `true`.

Svelte repl [here](https://svelte.technology/repl?version=2.15.3&gist=064f8fea7ac8e7fc91bdaf78e223ec00). Inspecting the rendered output shows how without an attribute value, a value of "true" is rendered.


Issue discussion:
IIRC that behaviour is valid for XHTML. Maybe Svelte is doing something here …
Only with HTML5 it became valid for an attribute to not have a value. That is, it's mere presence implied the value of `true`.

Solution patch:
diff --git a/src/compile/render-dom/wrappers/Element/Attribute.ts b/src/compile/render-dom/wrappers/Element/Attribute.ts
--- a/src/compile/render-dom/wrappers/Element/Attribute.ts
+++ b/src/compile/render-dom/wrappers/Element/Attribute.ts
@@ -187,7 +187,7 @@ export default class AttributeWrapper {
 						? `${element.var}.${propertyName} = ${value};`
 						: isDataSet
 							? `${element.var}.dataset.${camelCaseName} = ${value};`
-							: `${method}(${element.var}, "${name}", ${value});`
+							: `${method}(${element.var}, "${name}", ${value === true ? '""' : value});`
 			);
 
 			block.builders.hydrate.addLine(statement);
@@ -207,9 +207,9 @@ export default class AttributeWrapper {
 	}
 
 	stringify() {
-		const value = this.node.chunks;
+		if (this.node.isTrue) return '';
 
-		if (value === true) return '';
+		const value = this.node.chunks;
 		if (value.length === 0) return `=""`;
 
 		return `="${value.map(chunk => {


Test patch:
diff --git a/test/runtime/samples/attribute-unknown-without-value/_config.js b/test/runtime/samples/attribute-unknown-without-value/_config.js
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/attribute-unknown-without-value/_config.js
@@ -0,0 +1,3 @@
+export default {
+	html: '<div potato=""></div>'
+};
\ No newline at end of file
diff --git a/test/runtime/samples/attribute-unknown-without-value/main.html b/test/runtime/samples/attribute-unknown-without-value/main.html
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/attribute-unknown-without-value/main.html
@@ -0,0 +1 @@
+<div potato></div>
\ No newline at end of file
Repository: sveltejs/svelte (JavaScript)
Date: 2019-01-15 23:19:29+00:00
Task type: Bug Fix

Issue:
(v3) alpha 17 regression: input checked binding not working
It works in 15 and 16. Here are comparisons:

### Alpha 16, works:

https://v3.svelte.technology/repl?version=3.0.0-alpha16&gist=c7b2ce75156639a2fae714098db7beb2

### Alpha 17, brokedvhjen:

https://v3.svelte.technology/repl?version=3.0.0-alpha17&gist=73d6b9fd021fb610415a3f542626f367

Click on a check box, and you'll see the value doesn't update.


Mac OS High Sierra 10.13.6 (17G65)
Google Chrome Version 71.0.3578.98 (Official Build) (64-bit)


Issue discussion:

Solution patch:
diff --git a/src/compile/nodes/shared/TemplateScope.ts b/src/compile/nodes/shared/TemplateScope.ts
--- a/src/compile/nodes/shared/TemplateScope.ts
+++ b/src/compile/nodes/shared/TemplateScope.ts
@@ -1,6 +1,6 @@
 export default class TemplateScope {
 	names: Set<string>;
-	dependenciesForName: Map<string, string>;
+	dependenciesForName: Map<string, Set<string>>;
 	mutables: Set<string>;
 	parent?: TemplateScope;
 
@@ -11,7 +11,7 @@ export default class TemplateScope {
 		this.mutables = new Set();
 	}
 
-	add(name, dependencies) {
+	add(name, dependencies: Set<string>) {
 		this.names.add(name);
 		this.dependenciesForName.set(name, dependencies);
 		return this;
@@ -23,8 +23,10 @@ export default class TemplateScope {
 	}
 
 	setMutable(name: string) {
-		if (this.names.has(name)) this.mutables.add(name);
-		else if (this.parent) this.parent.setMutable(name);
+		if (this.names.has(name)) {
+			this.mutables.add(name);
+			if (this.parent && this.dependenciesForName.has(name)) this.dependenciesForName.get(name).forEach(dep => this.parent.setMutable(dep));
+		} else if (this.parent) this.parent.setMutable(name);
 		else this.mutables.add(name);
 	}
 


Test patch:
diff --git a/test/runtime/samples/mutation-tracking-across-sibling-scopes/_config.js b/test/runtime/samples/mutation-tracking-across-sibling-scopes/_config.js
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/mutation-tracking-across-sibling-scopes/_config.js
@@ -0,0 +1,12 @@
+export default {
+	async test({ assert, component, target }) {
+		assert.htmlEqual(component.div.innerHTML, '<div>+</div><div>-</div>');
+
+		const event = new window.Event('change');
+		const input = target.querySelector('input');
+		input.checked = false;
+		await input.dispatchEvent(event);
+
+		assert.htmlEqual(component.div.innerHTML, '<div>-</div><div>-</div>');
+	}
+};
\ No newline at end of file
diff --git a/test/runtime/samples/mutation-tracking-across-sibling-scopes/main.html b/test/runtime/samples/mutation-tracking-across-sibling-scopes/main.html
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/mutation-tracking-across-sibling-scopes/main.html
@@ -0,0 +1,18 @@
+{#each things as thing}
+	<div>
+		<input type=checkbox bind:checked={thing.ok} />
+	</div>
+{/each}
+
+<div bind:this={div}>
+	{#each things as other}
+		<div>
+			{other.ok ? '+' : '-'}
+		</div>
+	{/each}
+</div>
+
+<script>
+	const things = [{ ok: true }, { ok: false }];
+	export let div;
+</script>
\ No newline at end of file
Repository: sveltejs/svelte (JavaScript)
Date: 2019-01-19 02:29:59+00:00
Task type: Bug Fix

Issue:
Scroll bindings broken
https://v3.svelte.technology/repl?version=3.0.0-alpha18&demo=parallax


Issue discussion:

Solution patch:
diff --git a/src/compile/render-dom/wrappers/Window.ts b/src/compile/render-dom/wrappers/Window.ts
--- a/src/compile/render-dom/wrappers/Window.ts
+++ b/src/compile/render-dom/wrappers/Window.ts
@@ -146,9 +146,9 @@ export default class WindowWrapper extends Wrapper {
 					${scrolling} = true;
 					clearTimeout(${scrolling_timeout});
 					window.scrollTo(${
-						bindings.scrollX ? `current["${bindings.scrollX}"]` : `window.pageXOffset`
+						bindings.scrollX ? `ctx.${bindings.scrollX}` : `window.pageXOffset`
 					}, ${
-						bindings.scrollY ? `current["${bindings.scrollY}"]` : `window.pageYOffset`
+						bindings.scrollY ? `ctx.${bindings.scrollY}` : `window.pageYOffset`
 					});
 					${scrolling_timeout} = setTimeout(${clear_scrolling}, 100);
 				}


Test patch:
diff --git a/test/js/samples/window-binding-scroll/expected.js b/test/js/samples/window-binding-scroll/expected.js
--- a/test/js/samples/window-binding-scroll/expected.js
+++ b/test/js/samples/window-binding-scroll/expected.js
@@ -29,7 +29,7 @@ function create_fragment($$, ctx) {
 			if (changed.y && !scrolling) {
 				scrolling = true;
 				clearTimeout(scrolling_timeout);
-				window.scrollTo(window.pageXOffset, current["y"]);
+				window.scrollTo(window.pageXOffset, ctx.y);
 				scrolling_timeout = setTimeout(clear_scrolling, 100);
 			}
Repository: sveltejs/svelte (JavaScript)
Date: 2019-01-19 15:18:19+00:00
Task type: Bug Fix

Issue:
Prevent writing to 'computed' values
[REPL](https://v3.svelte.technology/repl?version=3.0.0-alpha12&gist=589305828c887b6e7236e348db1393dd). Ideally, it wouldn't be possible to set `doubled` from outside `Nested`, because its value is set reactively.

Re-running reactive declarations when their assignees are dirty (as well as when theire dependents are dirty) *should* fix this, I think. It does mean adding new `if ($$dirty.xxx)` conditions though, which makes the bitmask idea even more appealing


Issue discussion:

Solution patch:
diff --git a/src/compile/Component.ts b/src/compile/Component.ts
--- a/src/compile/Component.ts
+++ b/src/compile/Component.ts
@@ -881,15 +881,10 @@ export default class Component {
 							scope = map.get(node);
 						}
 
-						if (parent && parent.type === 'AssignmentExpression' && node === parent.left) {
-							return this.skip();
-						}
-
 						if (node.type === 'AssignmentExpression') {
 							assignees.add(getObject(node.left).name);
 						} else if (node.type === 'UpdateExpression') {
 							assignees.add(getObject(node.argument).name);
-							this.skip();
 						} else if (isReference(node, parent)) {
 							const object = getObject(node);
 							const { name } = object;


Test patch:
diff --git a/test/js/samples/dev-warning-missing-data-computed/expected.js b/test/js/samples/dev-warning-missing-data-computed/expected.js
--- a/test/js/samples/dev-warning-missing-data-computed/expected.js
+++ b/test/js/samples/dev-warning-missing-data-computed/expected.js
@@ -56,8 +56,8 @@ function instance($$self, $$props, $$invalidate) {
 		if ('foo' in $$props) $$invalidate('foo', foo = $$props.foo);
 	};
 
-	$$self.$$.update = ($$dirty = { foo: 1 }) => {
-		if ($$dirty.foo) {
+	$$self.$$.update = ($$dirty = { bar: 1, foo: 1 }) => {
+		if ($$dirty.bar || $$dirty.foo) {
 			bar = foo * 2; $$invalidate('bar', bar);
 		}
 	};
diff --git a/test/runtime/samples/reactive-values-readonly/_config.js b/test/runtime/samples/reactive-values-readonly/_config.js
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/reactive-values-readonly/_config.js
@@ -0,0 +1,21 @@
+export default {
+	html: `
+		<p>doubled: 2</p>
+	`,
+
+	test({ assert, component, target }) {
+		component.a = 2;
+
+		assert.equal(component.doubled, 4);
+		assert.htmlEqual(target.innerHTML, `
+			<p>doubled: 4</p>
+		`);
+
+		component.doubled = 6;
+
+		assert.equal(component.doubled, 4);
+		assert.htmlEqual(target.innerHTML, `
+			<p>doubled: 4</p>
+		`);
+	}
+};
diff --git a/test/runtime/samples/reactive-values-readonly/main.html b/test/runtime/samples/reactive-values-readonly/main.html
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/reactive-values-readonly/main.html
@@ -0,0 +1,8 @@
+<script>
+	export let a = 1;
+	export let doubled;
+
+	$: doubled = a * 2;
+</script>
+
+<p>doubled: {doubled}</p>
\ No newline at end of file
Repository: sveltejs/svelte (JavaScript)
Date: 2019-02-04 01:39:37+00:00
Task type: Bug Fix

Issue:
ASI confused by turning export statement into `$$props` destructuring
```html
<script>
	export let foo, bar
	(() => {})()
</script>
```

The `export` is turned into `let { foo, bar } = $$props` which causes a semicolon issue with the following line.


Issue discussion:

Solution patch:
diff --git a/src/compile/Component.ts b/src/compile/Component.ts
--- a/src/compile/Component.ts
+++ b/src/compile/Component.ts
@@ -744,10 +744,14 @@ export default class Component {
 										});
 									}
 
+									const suffix = code.original[declarator.end] === ';'
+										? ` = $$props`
+										: ` = $$props;`
+
 									if (declarator.id.end === declarator.end) {
-										code.appendLeft(declarator.end, ' = $$props');
+										code.appendLeft(declarator.end, suffix);
 									} else {
-										code.overwrite(declarator.id.end, declarator.end, ' = $$props');
+										code.overwrite(declarator.id.end, declarator.end, suffix);
 									}
 								}
 
@@ -823,7 +827,8 @@ export default class Component {
 			});
 
 			if (combining) {
-				code.appendLeft(c, ' } = $$props');
+				const suffix = code.original[c] === ';' ? ` } = $$props` : ` } = $$props;`;
+				code.appendLeft(c, suffix);
 			}
 		});
 	}


Test patch:
diff --git a/test/runtime/samples/prop-without-semicolon-b/_config.js b/test/runtime/samples/prop-without-semicolon-b/_config.js
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/prop-without-semicolon-b/_config.js
@@ -0,0 +1,7 @@
+export default {
+	props: {
+		name: 'world'
+	},
+
+	html: `<h1>Hello world!</h1>`
+};
\ No newline at end of file
diff --git a/test/runtime/samples/prop-without-semicolon-b/main.html b/test/runtime/samples/prop-without-semicolon-b/main.html
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/prop-without-semicolon-b/main.html
@@ -0,0 +1,6 @@
+<h1>Hello {name}!</h1>
+
+<script>
+	export let name
+	(() => {})()
+</script>
\ No newline at end of file
Repository: sveltejs/svelte (JavaScript)
Date: 2019-02-07 16:11:53+00:00
Task type: Bug Fix

Issue:
Cyclical dependency detection fails to account for scope
This throws an incorrect 'Cyclical dependency detected' error, because it thinks `b` depends on `a`:

```html
<script>
	export let x;
	
	let a;
	let b;
	
	$: a = b;
	$: b = (function(a) {
		return a;
	}(x));
</script>
```


Issue discussion:

Solution patch:
diff --git a/src/compile/Component.ts b/src/compile/Component.ts
--- a/src/compile/Component.ts
+++ b/src/compile/Component.ts
@@ -1002,7 +1002,8 @@ export default class Component {
 							const object = getObject(node);
 							const { name } = object;
 
-							if (name[0] === '$' || component.var_lookup.has(name)) {
+							const owner = scope.findOwner(name);
+							if ((!owner || owner === component.instance_scope) && (name[0] === '$' || component.var_lookup.has(name))) {
 								dependencies.add(name);
 							}
 


Test patch:
diff --git a/test/runtime/samples/reactive-values-non-cyclical/_config.js b/test/runtime/samples/reactive-values-non-cyclical/_config.js
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/reactive-values-non-cyclical/_config.js
@@ -0,0 +1,17 @@
+export default {
+	props: {
+		x: 42
+	},
+
+	html: `
+		<p>42 42</p>
+	`,
+
+	test({ assert, component, target }) {
+		component.x = 43;
+
+		assert.htmlEqual(target.innerHTML, `
+			<p>43 43</p>
+		`);
+	}
+};
diff --git a/test/runtime/samples/reactive-values-non-cyclical/main.html b/test/runtime/samples/reactive-values-non-cyclical/main.html
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/reactive-values-non-cyclical/main.html
@@ -0,0 +1,13 @@
+<script>
+	export let x;
+
+	let a;
+	let b;
+
+	$: a = b;
+	$: b = (function(a) {
+		return a;
+	}(x));
+</script>
+
+<p>{a} {b}</p>
\ No newline at end of file
diff --git a/test/validator/samples/reactive-declaration-cyclical/errors.json b/test/validator/samples/reactive-declaration-cyclical/errors.json
new file mode 100644
--- /dev/null
+++ b/test/validator/samples/reactive-declaration-cyclical/errors.json
@@ -0,0 +1,7 @@
+[{
+	"message": "Cyclical dependency detected",
+	"code": "cyclical-reactive-declaration",
+	"start": { "line": 5, "column": 1, "character": 35 },
+	"end": { "line": 5, "column": 14, "character": 48 },
+	"pos": 35
+}]
\ No newline at end of file
diff --git a/test/validator/samples/reactive-declaration-cyclical/input.html b/test/validator/samples/reactive-declaration-cyclical/input.html
new file mode 100644
--- /dev/null
+++ b/test/validator/samples/reactive-declaration-cyclical/input.html
@@ -0,0 +1,7 @@
+<script>
+	let a = 1;
+	let b = 2;
+
+	$: a = b + 1;
+	$: b = a + 1;
+</script>
\ No newline at end of file
Repository: sveltejs/svelte (JavaScript)
Date: 2019-02-17 17:36:20+00:00
Task type: Refactoring

Issue:
Proposal: `dev: true` only affects runtime warnings and errors
Right now, compiling with `dev: true` causes the compiler to emit a bunch of code to display additional runtime warnings and errors, to assist with debugging - and it also enables a compile-time warning for empty blocks. As far as I can tell, the empty blocks warning is the only compiler-time thing it affects.

This seems weird, and I think it would be nicer if `dev: true` _only_ affected runtime things. This would mean that the empty block compile-time warning would always be emitted - so this issues can go along with #2040, which makes it simpler to suppress specific warnings at compile time.


Issue discussion:

Solution patch:
diff --git a/src/compile/nodes/shared/Node.ts b/src/compile/nodes/shared/Node.ts
--- a/src/compile/nodes/shared/Node.ts
+++ b/src/compile/nodes/shared/Node.ts
@@ -49,7 +49,6 @@ export default class Node {
 	}
 
 	warnIfEmptyBlock() {
-		if (!this.component.compileOptions.dev) return;
 		if (!/Block$/.test(this.type) || !this.children) return;
 		if (this.children.length > 1) return;
 


Test patch:
diff --git a/test/validator/samples/empty-block-dev/_config.js b/test/validator/samples/empty-block-dev/_config.js
deleted file mode 100644
--- a/test/validator/samples/empty-block-dev/_config.js
+++ /dev/null
@@ -1,3 +0,0 @@
-export default {
-	dev: true
-};
\ No newline at end of file
diff --git a/test/validator/samples/empty-block-prod/input.svelte b/test/validator/samples/empty-block-prod/input.svelte
deleted file mode 100644
--- a/test/validator/samples/empty-block-prod/input.svelte
+++ /dev/null
@@ -1,5 +0,0 @@
-{#each things as thing}
-
-{/each}
-
-{#each things as thing}{/each}
\ No newline at end of file
diff --git a/test/validator/samples/empty-block-prod/warnings.json b/test/validator/samples/empty-block-prod/warnings.json
deleted file mode 100644
--- a/test/validator/samples/empty-block-prod/warnings.json
+++ /dev/null
@@ -1 +0,0 @@
-[]
\ No newline at end of file
diff --git a/test/validator/samples/empty-block-dev/input.svelte b/test/validator/samples/empty-block/input.svelte
similarity index 100%
rename from test/validator/samples/empty-block-dev/input.svelte
rename to test/validator/samples/empty-block/input.svelte
diff --git a/test/validator/samples/empty-block-dev/warnings.json b/test/validator/samples/empty-block/warnings.json
similarity index 100%
rename from test/validator/samples/empty-block-dev/warnings.json
rename to test/validator/samples/empty-block/warnings.json
Repository: sveltejs/svelte (JavaScript)
Date: 2019-02-17 19:18:33+00:00
Task type: Bug Fix

Issue:
Nesting slots broke in alpha19 
[REPL](https://v3.svelte.technology/repl?version=3.0.0-alpha24&gist=82d12c72e4da0e37e5573ce188570464)

Nested provides a slot that should get injected into Sub. Since alpha19 it throws `Failed to execute 'appendChild' on 'Node': The new child element contains the parent.`.



Issue discussion:

Solution patch:
diff --git a/src/compile/render-dom/wrappers/Element/index.ts b/src/compile/render-dom/wrappers/Element/index.ts
--- a/src/compile/render-dom/wrappers/Element/index.ts
+++ b/src/compile/render-dom/wrappers/Element/index.ts
@@ -203,6 +203,10 @@ export default class ElementWrapper extends Wrapper {
 
 		if (this.slot_block) {
 			block.parent.addDependencies(block.dependencies);
+
+			// appalling hack
+			block.wrappers.splice(block.wrappers.indexOf(this), 1);
+			this.slot_block.wrappers.push(this);
 		}
 	}
 
@@ -216,13 +220,13 @@ export default class ElementWrapper extends Wrapper {
 
 		if (this.node.name === 'noscript') return;
 
-		const node = this.var;
-		const nodes = parentNodes && block.getUniqueName(`${this.var}_nodes`) // if we're in unclaimable territory, i.e. <head>, parentNodes is null
-
 		if (this.slot_block) {
 			block = this.slot_block;
 		}
 
+		const node = this.var;
+		const nodes = parentNodes && block.getUniqueName(`${this.var}_nodes`) // if we're in unclaimable territory, i.e. <head>, parentNodes is null
+
 		block.addVariable(node);
 		const renderStatement = this.getRenderStatement();
 		block.builders.create.addLine(


Test patch:
diff --git a/test/runtime/samples/component-slot-nested-in-element/One.svelte b/test/runtime/samples/component-slot-nested-in-element/One.svelte
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/component-slot-nested-in-element/One.svelte
@@ -0,0 +1,11 @@
+<script>
+	import Two from './Two.svelte';
+</script>
+
+<Two>
+	<div slot="b">
+		<div>
+			<slot name="a"></slot>
+		</div>
+	</div>
+</Two>
\ No newline at end of file
diff --git a/test/runtime/samples/component-slot-nested-in-element/Two.svelte b/test/runtime/samples/component-slot-nested-in-element/Two.svelte
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/component-slot-nested-in-element/Two.svelte
@@ -0,0 +1 @@
+<slot name="b"></slot>
\ No newline at end of file
diff --git a/test/runtime/samples/component-slot-nested-in-element/_config.js b/test/runtime/samples/component-slot-nested-in-element/_config.js
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/component-slot-nested-in-element/_config.js
@@ -0,0 +1,9 @@
+export default {
+	html: `
+		<div slot="b">
+			<div>
+				<div slot="a">a</div>
+			</div>
+		</div>
+	`
+};
diff --git a/test/runtime/samples/component-slot-nested-in-element/main.svelte b/test/runtime/samples/component-slot-nested-in-element/main.svelte
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/component-slot-nested-in-element/main.svelte
@@ -0,0 +1,7 @@
+<script>
+	import One from './One.svelte';
+</script>
+
+<One>
+	<div slot="a">a</div>
+</One>
\ No newline at end of file
Repository: sveltejs/svelte (JavaScript)
Date: 2019-02-20 14:09:01+00:00
Task type: Bug Fix

Issue:
Named slot bug
A named slot that contains a variable has a bug in v3.0.0-beta.5

https://v3.svelte.technology/repl?version=3.0.0-beta.5&gist=89e16e7c3cc78b52369145fc8552ebf1
vs 
https://v3.svelte.technology/repl?version=3.0.0-beta.3&gist=89e16e7c3cc78b52369145fc8552ebf1


Issue discussion:

Solution patch:
diff --git a/src/compile/render-dom/wrappers/Element/index.ts b/src/compile/render-dom/wrappers/Element/index.ts
--- a/src/compile/render-dom/wrappers/Element/index.ts
+++ b/src/compile/render-dom/wrappers/Element/index.ts
@@ -205,8 +205,8 @@ export default class ElementWrapper extends Wrapper {
 			block.parent.addDependencies(block.dependencies);
 
 			// appalling hack
-			block.wrappers.splice(block.wrappers.indexOf(this), 1);
-			this.slot_block.wrappers.push(this);
+			block.parent.wrappers.splice(block.parent.wrappers.indexOf(this), 1);
+			block.wrappers.push(this);
 		}
 	}
 
diff --git a/src/compile/render-dom/wrappers/MustacheTag.ts b/src/compile/render-dom/wrappers/MustacheTag.ts
--- a/src/compile/render-dom/wrappers/MustacheTag.ts
+++ b/src/compile/render-dom/wrappers/MustacheTag.ts
@@ -2,6 +2,7 @@ import Renderer from '../Renderer';
 import Block from '../Block';
 import Node from '../../nodes/shared/Node';
 import Tag from './shared/Tag';
+import Wrapper from './shared/Wrapper';
 
 export default class MustacheTagWrapper extends Tag {
 	var = 'text';


Test patch:
diff --git a/test/runtime/samples/component-slot-named-b/Nested.svelte b/test/runtime/samples/component-slot-named-b/Nested.svelte
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/component-slot-named-b/Nested.svelte
@@ -0,0 +1 @@
+<slot name="name"></slot>
\ No newline at end of file
diff --git a/test/runtime/samples/component-slot-named-b/_config.js b/test/runtime/samples/component-slot-named-b/_config.js
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/component-slot-named-b/_config.js
@@ -0,0 +1,7 @@
+export default {
+	preserveIdentifiers: true,
+
+	html: `
+		<span slot="name">Hello world</span>
+	`
+};
diff --git a/test/runtime/samples/component-slot-named-b/main.svelte b/test/runtime/samples/component-slot-named-b/main.svelte
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/component-slot-named-b/main.svelte
@@ -0,0 +1,9 @@
+<script>
+	import Nested from './Nested.svelte';
+
+	let name = 'world';
+</script>
+
+<Nested>
+	<span slot="name">Hello {name}</span>
+</Nested>
\ No newline at end of file
Repository: sveltejs/svelte (JavaScript)
Date: 2019-02-22 04:34:57+00:00
Task type: Bug Fix

Issue:
Named slot bug
v3.0.0-beta.7

Named slot bug (sorry)

https://v3.svelte.technology/repl?version=3.0.0-beta.7&gist=cbc0e3e7a6de3963a72546e95361b369
vs
https://v3.svelte.technology/repl?version=3.0.0-beta.6&gist=cbc0e3e7a6de3963a72546e95361b369



Issue discussion:
A related bug: https://v3.svelte.technology/repl?version=3.0.0-beta.7&gist=bfcbe5396ef0dcb5f1ad252b7650b31d

Looks like the names of the two `<Nested>` component instances aren't being deconflicted

Solution patch:
diff --git a/src/compile/render-dom/wrappers/Element/index.ts b/src/compile/render-dom/wrappers/Element/index.ts
--- a/src/compile/render-dom/wrappers/Element/index.ts
+++ b/src/compile/render-dom/wrappers/Element/index.ts
@@ -132,7 +132,7 @@ export default class ElementWrapper extends Wrapper {
 					const name = attribute.getStaticValue();
 
 					if (!(owner as InlineComponentWrapper).slots.has(name)) {
-						const child_block = block.parent.child({
+						const child_block = block.child({
 							comment: createDebuggingComment(node, this.renderer.component),
 							name: this.renderer.component.getUniqueName(`create_${sanitize(name)}_slot`)
 						});
@@ -205,7 +205,8 @@ export default class ElementWrapper extends Wrapper {
 			block.parent.addDependencies(block.dependencies);
 
 			// appalling hack
-			block.parent.wrappers.splice(block.parent.wrappers.indexOf(this), 1);
+			const index = block.parent.wrappers.indexOf(this);
+			block.parent.wrappers.splice(index, 1);
 			block.wrappers.push(this);
 		}
 	}


Test patch:
diff --git a/test/runtime/samples/component-slot-named-c/Nested.svelte b/test/runtime/samples/component-slot-named-c/Nested.svelte
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/component-slot-named-c/Nested.svelte
@@ -0,0 +1 @@
+<slot name="name"></slot>
\ No newline at end of file
diff --git a/test/runtime/samples/component-slot-named-c/_config.js b/test/runtime/samples/component-slot-named-c/_config.js
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/component-slot-named-c/_config.js
@@ -0,0 +1,6 @@
+export default {
+	html: `
+		<span slot="name">Hello</span>
+		<span slot="name">world</span>
+	`
+};
diff --git a/test/runtime/samples/component-slot-named-c/main.svelte b/test/runtime/samples/component-slot-named-c/main.svelte
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/component-slot-named-c/main.svelte
@@ -0,0 +1,11 @@
+<script>
+	import Nested from './Nested.svelte';
+</script>
+
+<Nested>
+	<span slot="name">Hello</span>
+</Nested>
+
+<Nested>
+	<span slot="name">world</span>
+</Nested>
\ No newline at end of file
Repository: sveltejs/svelte (JavaScript)
Date: 2019-03-02 18:40:31+00:00
Task type: Bug Fix

Issue:
Can't use destructured variable declaration for event handler
[REPL](https://v3.svelte.technology/repl?version=3.0.0-beta.9&gist=45aaa8708abb38be40448679270a2122). `const handler` works, but `const { handler }` doesn't, because of a bug in some AST traversal somewhere


Issue discussion:

Solution patch:
diff --git a/src/compile/nodes/EventHandler.ts b/src/compile/nodes/EventHandler.ts
--- a/src/compile/nodes/EventHandler.ts
+++ b/src/compile/nodes/EventHandler.ts
@@ -32,7 +32,7 @@ export default class EventHandler extends Node {
 				if (node && node.type === 'VariableDeclaration') {
 					// for `const handleClick = () => {...}`, we want the [arrow] function expression node
 					const declarator = node.declarations.find(d => d.id.name === info.expression.name);
-					node = declarator.init;
+					node = declarator && declarator.init;
 				}
 
 				if (node && /Function/.test(node.type) && node.params.length === 0) {


Test patch:
diff --git a/test/runtime/samples/event-handler-destructured/_config.js b/test/runtime/samples/event-handler-destructured/_config.js
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/event-handler-destructured/_config.js
@@ -0,0 +1,15 @@
+export default {
+	html: `
+		<button>clicked: false</button>
+	`,
+
+	async test({ assert, component, target, window }) {
+		const button = target.querySelector('button');
+		const event = new window.MouseEvent('click');
+
+		await button.dispatchEvent(event);
+		assert.htmlEqual(target.innerHTML, `
+			<button>clicked: true</button>
+		`);
+	}
+};
diff --git a/test/runtime/samples/event-handler-destructured/main.svelte b/test/runtime/samples/event-handler-destructured/main.svelte
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/event-handler-destructured/main.svelte
@@ -0,0 +1,16 @@
+<script>
+	function get_handlers() {
+		return {
+			handle_click: () => {
+				clicked = true;
+			}
+		};
+	}
+
+	let clicked = false;
+	const { handle_click } = get_handlers();
+</script>
+
+<button on:click={handle_click}>
+	clicked: {clicked}
+</button>
\ No newline at end of file
Repository: sveltejs/svelte (JavaScript)
Date: 2019-03-06 17:43:11+00:00
Task type: Bug Fix

Issue:
Parser doesn't insist on whitespace after @html
[REPL](https://v3.svelte.technology/repl?version=3.0.0-beta.10&gist=240ec320582206305808ddbc18d26bdb). This seems bad

```html
<script>
	let string = `this string contains some <strong>HTML!!!</strong>`;
</script>

<p>{@htmlstring}</p>
```


Issue discussion:

Solution patch:
diff --git a/src/parse/state/mustache.ts b/src/parse/state/mustache.ts
--- a/src/parse/state/mustache.ts
+++ b/src/parse/state/mustache.ts
@@ -316,6 +316,8 @@ export default function mustache(parser: Parser) {
 		}
 	} else if (parser.eat('@html')) {
 		// {@html content} tag
+		parser.requireWhitespace();
+
 		const expression = readExpression(parser);
 
 		parser.allowWhitespace();


Test patch:
diff --git a/test/parser/samples/raw-mustaches-whitespace-error/error.json b/test/parser/samples/raw-mustaches-whitespace-error/error.json
new file mode 100644
--- /dev/null
+++ b/test/parser/samples/raw-mustaches-whitespace-error/error.json
@@ -0,0 +1,10 @@
+{
+	"code": "missing-whitespace",
+	"message": "Expected whitespace",
+	"start": {
+		"line": 1,
+		"column": 6,
+		"character": 6
+	},
+	"pos": 6
+}
diff --git a/test/parser/samples/raw-mustaches-whitespace-error/input.svelte b/test/parser/samples/raw-mustaches-whitespace-error/input.svelte
new file mode 100644
--- /dev/null
+++ b/test/parser/samples/raw-mustaches-whitespace-error/input.svelte
@@ -0,0 +1 @@
+{@htmlfoo}
Repository: sveltejs/svelte (JavaScript)
Date: 2019-03-09 16:23:03+00:00
Task type: Bug Fix

Issue:
Assigning to a property of `this` in a function triggers invalidation of “undefined”
[Minimal example:](https://v3.svelte.technology/repl?version=3.0.0-beta.11&gist=1ad69afee5b85aa775178b32e033494a)
```html
<script>
	function make_uppercase() {
		this.value = this.value.toUpperCase();
	}
</script>
<input on:input={make_uppercase}>
```

In that function, `this` will be the element the event was fired on.

Incorrect generated JS:

```js
function make_uppercase() {
	this.value = this.value.toUpperCase(); $$invalidate('undefined', undefined);
}
```

There should be no `$$invalid('undefined', undefined);`.

A workaround: use `event.currentTarget` instead of `this`.


Issue discussion:

Solution patch:
diff --git a/src/compile/render-dom/index.ts b/src/compile/render-dom/index.ts
--- a/src/compile/render-dom/index.ts
+++ b/src/compile/render-dom/index.ts
@@ -165,9 +165,14 @@ export default function dom(
 				}
 
 				if (node.type === 'AssignmentExpression') {
-					const names = node.left.type === 'MemberExpression'
-						? [getObject(node.left).name]
-						: extractNames(node.left);
+					let names = [];
+
+					if (node.left.type === 'MemberExpression') {
+						const left_object_name = getObject(node.left).name;
+						left_object_name && (names = [left_object_name]);
+					} else {
+						names = extractNames(node.left);
+					}
 
 					if (node.operator === '=' && nodes_match(node.left, node.right)) {
 						const dirty = names.filter(name => {


Test patch:
diff --git a/test/js/samples/dont-invalidate-this/expected.js b/test/js/samples/dont-invalidate-this/expected.js
new file mode 100644
--- /dev/null
+++ b/test/js/samples/dont-invalidate-this/expected.js
@@ -0,0 +1,42 @@
+/* generated by Svelte vX.Y.Z */
+import { SvelteComponent as SvelteComponent_1, addListener, createElement, detachNode, init, insert, noop, safe_not_equal } from "svelte/internal";
+
+function create_fragment(ctx) {
+	var input, dispose;
+
+	return {
+		c() {
+			input = createElement("input");
+			dispose = addListener(input, "input", make_uppercase);
+		},
+
+		m(target, anchor) {
+			insert(target, input, anchor);
+		},
+
+		p: noop,
+		i: noop,
+		o: noop,
+
+		d(detach) {
+			if (detach) {
+				detachNode(input);
+			}
+
+			dispose();
+		}
+	};
+}
+
+function make_uppercase() {
+	this.value = this.value.toUpperCase();
+}
+
+class SvelteComponent extends SvelteComponent_1 {
+	constructor(options) {
+		super();
+		init(this, options, null, create_fragment, safe_not_equal);
+	}
+}
+
+export default SvelteComponent;
diff --git a/test/js/samples/dont-invalidate-this/input.svelte b/test/js/samples/dont-invalidate-this/input.svelte
new file mode 100644
--- /dev/null
+++ b/test/js/samples/dont-invalidate-this/input.svelte
@@ -0,0 +1,6 @@
+<script>
+	function make_uppercase() {
+		this.value = this.value.toUpperCase();
+	}
+</script>
+<input on:input={make_uppercase}>
Repository: sveltejs/svelte (JavaScript)
Date: 2019-06-29 23:03:07+00:00
Task type: Bug Fix

Issue:
Custom at-rules don't work if not in the last declaration block of a <style> tag
[REPL](https://svelte.dev/repl/6dd5a9e4a7d14a949bfb0850339d8a4b?version=3.6.1)

Custom at-rules, such as `@apply`, aren't parsed properly (and cause a compile-time error!) unless they are in the last declaration block of the component's styles.


Issue discussion:
This might be something else that #2995 aims to take care of.

Solution patch:
diff --git a/src/compiler/compile/css/Stylesheet.ts b/src/compiler/compile/css/Stylesheet.ts
--- a/src/compiler/compile/css/Stylesheet.ts
+++ b/src/compiler/compile/css/Stylesheet.ts
@@ -315,7 +315,14 @@ export default class Stylesheet {
 
 				leave: (node: Node) => {
 					if (node.type === 'Rule' || node.type === 'Atrule') stack.pop();
-					if (node.type === 'Atrule') current_atrule = stack[stack.length - 1] as Atrule;
+					if (node.type === 'Atrule') {
+						current_atrule = null;
+						for (let i = stack.length - 1; i >= 0; i--) {
+							if (stack[i] instanceof Atrule) {
+								current_atrule = stack[i] as Atrule;
+							}
+						}
+					}
 				}
 			});
 		} else {


Test patch:
diff --git a/test/css/samples/unknown-at-rule-with-following-rules/expected.css b/test/css/samples/unknown-at-rule-with-following-rules/expected.css
new file mode 100644
--- /dev/null
+++ b/test/css/samples/unknown-at-rule-with-following-rules/expected.css
@@ -0,0 +1 @@
+div.svelte-xyz{@apply --funky-div;}
\ No newline at end of file
diff --git a/test/css/samples/unknown-at-rule-with-following-rules/input.svelte b/test/css/samples/unknown-at-rule-with-following-rules/input.svelte
new file mode 100644
--- /dev/null
+++ b/test/css/samples/unknown-at-rule-with-following-rules/input.svelte
@@ -0,0 +1,11 @@
+<div></div>
+
+<style>
+	div {
+		@apply --funky-div;
+	}
+
+	div {
+		
+	}
+</style>
\ No newline at end of file
Repository: sveltejs/svelte (JavaScript)
Date: 2019-06-30 21:42:26+00:00
Task type: Bug Fix

Issue:
:not(...) styles are broken
[REPL](https://svelte.technology/repl?version=2.13.1&gist=c80e2cda5f07897ad9eaada7df570cc0). The encapsulator should treat `:not(selector)` as `*:not(selector)`, but it doesn't.


Issue discussion:
I don't think it is a svelte bug. 
This is the normal behaviour in CSS. 
See this codepen : https://codepen.io/thollander/pen/JzJQKO?editors=1100

The color is inherited by default. 
https://www.w3schools.com/cssref/pr_text_color.asp
So it takes the color of the body property which validates the rule `:not(p)`
However, in the example, you can see border hasn't the same behaviour.


Updated REPL that shows the bug better: https://svelte.dev/repl/3c70b1effcf4442a8280b1c5db8c6f10?version=3.6.2

`:not(xxx)` should be converted to `.svelte-xyz123:not(xxx)`

Solution patch:
diff --git a/src/compiler/compile/css/Selector.ts b/src/compiler/compile/css/Selector.ts
--- a/src/compiler/compile/css/Selector.ts
+++ b/src/compiler/compile/css/Selector.ts
@@ -61,7 +61,10 @@ export default class Selector {
 			let i = block.selectors.length;
 			while (i--) {
 				const selector = block.selectors[i];
-				if (selector.type === 'PseudoElementSelector' || selector.type === 'PseudoClassSelector') continue;
+				if (selector.type === 'PseudoElementSelector' || selector.type === 'PseudoClassSelector') {
+					if (i === 0) code.prependRight(selector.start, attr);
+					continue;
+				}
 
 				if (selector.type === 'TypeSelector' && selector.name === '*') {
 					code.overwrite(selector.start, selector.end, attr);


Test patch:
diff --git a/test/css/samples/not-selector/expected.css b/test/css/samples/not-selector/expected.css
new file mode 100644
--- /dev/null
+++ b/test/css/samples/not-selector/expected.css
@@ -0,0 +1 @@
+.svelte-xyz:not(.foo){color:red}
\ No newline at end of file
diff --git a/test/css/samples/not-selector/input.svelte b/test/css/samples/not-selector/input.svelte
new file mode 100644
--- /dev/null
+++ b/test/css/samples/not-selector/input.svelte
@@ -0,0 +1,8 @@
+<p class="foo">foo</p>
+<p class="bar">bar</p>
+
+<style>
+	:not(.foo) {
+		color: red;
+	}
+</style>
\ No newline at end of file
Repository: sveltejs/svelte (JavaScript)
Date: 2019-07-02 02:42:00+00:00
Task type: Bug Fix

Issue:
Shorthand methods in object literals disappear
This works fine:

```html
<script>
	import Greeter from './Greeter.svelte';
	const object = {
		getName() {
			return 'foo';
		}
	};
</script>
<Greeter thing={object} />
```

This breaks:

```html
<script>
	import Greeter from './Greeter.svelte';
</script>
<Greeter thing={{
	getName() {
		return 'foo';
	}
}} />
```

```
Can't find variable: getNamefunc_1
```

Looks like there's some too greedy function hoisting going on.

REPL: https://svelte.dev/repl/d1fcf63ccfea462f948fcc4cc16c3028?version=3.4.4

---

EDIT: Another example of shorthand methods breaking in a different way:

```html
<script>
	import Greeter from './Greeter.svelte';
	let name = 'foo';
</script>

<Greeter thing={{
	getName() {
		return name;
	}
}} />
```

Compiler refuses to compile and says: `Unexpected token (Note that you need plugins to import files that are not JavaScript)`

https://svelte.dev/repl/6e2cf0c00f85488195f4a47eee22c1e0?version=3.4.4


Issue discussion:
"Unexpected token (Note that you need plugins to import files that are not JavaScript)" is an error from Rollup actually, which generally indicates that the Svelte compiler is outputting invalid js, in this case `{ getNamectx.func }`.

Solution patch:
diff --git a/src/compiler/compile/nodes/shared/Expression.ts b/src/compiler/compile/nodes/shared/Expression.ts
--- a/src/compiler/compile/nodes/shared/Expression.ts
+++ b/src/compiler/compile/nodes/shared/Expression.ts
@@ -442,6 +442,10 @@ export default class Expression {
 						`);
 					}
 
+					if (parent && parent.method) {
+						code.prependRight(node.start, ': ');
+					}
+
 					function_expression = null;
 					dependencies = null;
 					contextual_dependencies = null;


Test patch:
diff --git a/test/runtime/samples/shorthand-method-in-template/Foo.svelte b/test/runtime/samples/shorthand-method-in-template/Foo.svelte
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/shorthand-method-in-template/Foo.svelte
@@ -0,0 +1,5 @@
+<script>
+	export let bar;
+</script>
+
+{bar.answer()}
\ No newline at end of file
diff --git a/test/runtime/samples/shorthand-method-in-template/_config.js b/test/runtime/samples/shorthand-method-in-template/_config.js
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/shorthand-method-in-template/_config.js
@@ -0,0 +1,3 @@
+export default {
+	html: '42'
+};
\ No newline at end of file
diff --git a/test/runtime/samples/shorthand-method-in-template/main.svelte b/test/runtime/samples/shorthand-method-in-template/main.svelte
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/shorthand-method-in-template/main.svelte
@@ -0,0 +1,9 @@
+<script>
+	import Foo from './Foo.svelte';
+</script>
+
+<Foo bar={{
+	answer() {
+		return 42;
+	}
+}} />
\ No newline at end of file
Repository: sveltejs/svelte (JavaScript)
Date: 2019-07-03 19:17:20+00:00
Task type: Bug Fix

Issue:
`get_store_value` doesn't account for RxJS observables
Somewhat adjacent to https://github.com/sveltejs/sapper/issues/781 but I think there's other stuff going on there too.

The support we added for RxJS observables (i.e., allowing for the `.subscribe()` method to also return an _object_ with an `.unsubscribe()` method) does not look like it extended to `get_store_value`.


Issue discussion:
Here is a minimal repl that demonstrates the bug I was discussing in sveltejs/sapper#781. https://svelte.dev/repl/8bf28363bde34ecb8fa4e9b91a9e397a?version=3.6.3

(I had misdiagnosed the problem earlier and it didn't deal with sapper, so I have closed it)

Solution patch:
diff --git a/src/runtime/internal/ssr.ts b/src/runtime/internal/ssr.ts
--- a/src/runtime/internal/ssr.ts
+++ b/src/runtime/internal/ssr.ts
@@ -114,9 +114,15 @@ export function create_ssr_component(fn) {
 	};
 }
 
+/**
+ * Get the current value from a store by subscribing and immediately unsubscribing.
+ * @param store readable
+ */
 export function get_store_value<T>(store: Readable<T>): T | undefined {
 	let value;
-	store.subscribe(_ => value = _)();
+	const unsubscribe: any = store.subscribe(_ => value = _);
+	if (unsubscribe.unsubscribe) unsubscribe.unsubscribe();
+	else unsubscribe();
 	return value;
 }
 
diff --git a/src/runtime/store/index.ts b/src/runtime/store/index.ts
--- a/src/runtime/store/index.ts
+++ b/src/runtime/store/index.ts
@@ -1,4 +1,5 @@
 import { run_all, noop, safe_not_equal, is_function } from 'svelte/internal';
+export { get_store_value as get } from 'svelte/internal';
 
 /** Callback to inform of a value updates. */
 type Subscriber<T> = (value: T) => void;
@@ -188,14 +189,4 @@ export function derived<T, S extends Stores>(
 			};
 		}
 	};
-}
-
-/**
- * Get the current value from a store by subscribing and immediately unsubscribing.
- * @param store readable
- */
-export function get<T>(store: Readable<T>): T {
-	let value: T | undefined;
-	store.subscribe((_: T) => value = _)();
-	return value as T;
-}
+}
\ No newline at end of file


Test patch:
diff --git a/test/store/index.ts b/test/store/index.ts
--- a/test/store/index.ts
+++ b/test/store/index.ts
@@ -329,5 +329,18 @@ describe('store', () => {
 			const store = readable(42, () => { });
 			assert.equal(get(store), 42);
 		});
+
+		it('works with RxJS-style observables', () => {
+			const observable = {
+				subscribe(fn) {
+					fn(42);
+					return {
+						unsubscribe: () => {}
+					}
+				}
+			};
+
+			assert.equal(get(observable), 42);
+		});
 	});
 });
Repository: sveltejs/svelte (JavaScript)
Date: 2019-07-03 23:36:13+00:00
Task type: Bug Fix

Issue:
Bindings don't receive context from let variables
Via [this Stack Overflow question](https://stackoverflow.com/questions/56817063/how-to-bind-variable-declared-with-svelte-let-directive).

Using a `let` variable in a binding doesn't work — the binding function isn't passed the relevant context, it seems: https://svelte.dev/repl/278fe8b586f443889632803dcff8bcca?version=3.6.1


Issue discussion:

Solution patch:
diff --git a/src/compiler/compile/nodes/shared/Expression.ts b/src/compiler/compile/nodes/shared/Expression.ts
--- a/src/compiler/compile/nodes/shared/Expression.ts
+++ b/src/compiler/compile/nodes/shared/Expression.ts
@@ -138,7 +138,8 @@ export default class Expression {
 					}
 
 					if (template_scope.is_let(name)) {
-						if (!function_expression) {
+						if (!function_expression) { // TODO should this be `!lazy` ?
+							contextual_dependencies.add(name);
 							dependencies.add(name);
 						}
 					} else if (template_scope.names.has(name)) {


Test patch:
diff --git a/test/runtime/samples/component-slot-let-in-binding/Nested.svelte b/test/runtime/samples/component-slot-let-in-binding/Nested.svelte
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/component-slot-let-in-binding/Nested.svelte
@@ -0,0 +1,9 @@
+<script>
+	export let items;
+</script>
+
+<div>
+	{#each items as item, index}
+		<slot {index}/>
+	{/each}
+</div>
\ No newline at end of file
diff --git a/test/runtime/samples/component-slot-let-in-binding/_config.js b/test/runtime/samples/component-slot-let-in-binding/_config.js
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/component-slot-let-in-binding/_config.js
@@ -0,0 +1,26 @@
+export default {
+	html: `
+		<div>
+			<label>1: <input></label>
+			<label>2: <input></label>
+			<label>3: <input></label>
+		</div>
+	`,
+
+	ssrHtml: `
+		<div>
+			<label>1: <input value="a"></label>
+			<label>2: <input value="b"></label>
+			<label>3: <input value="c"></label>
+		</div>
+	`,
+
+	async test({ assert, component, target, window }) {
+		const inputs = target.querySelectorAll('input');
+
+		inputs[2].value = 'd';
+		await inputs[2].dispatchEvent(new window.Event('input'));
+
+		assert.deepEqual(component.letters, ['a', 'b', 'd']);
+	}
+};
diff --git a/test/runtime/samples/component-slot-let-in-binding/main.svelte b/test/runtime/samples/component-slot-let-in-binding/main.svelte
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/component-slot-let-in-binding/main.svelte
@@ -0,0 +1,11 @@
+<script>
+	import Nested from './Nested.svelte';
+
+	export let letters = ['a', 'b', 'c'];
+</script>
+
+<Nested items={letters} let:index>
+	<label>
+		{index + 1}: <input bind:value={letters[index]}>
+	</label>
+</Nested>
\ No newline at end of file