Repository: sveltejs/svelte (JavaScript)
Task: Bug Fix (2018-04-04 10:47:16+00:00)

Issue:
Spread properties cause CSS to be DCE'd incorrectly
[REPL](https://svelte.technology/repl?version=1.60.0&gist=678853cb781d28931abbc159c22d2d7f)

```html
<div {{...props}} >
	Big red Comic Sans
</div>

<style>
	.foo {
		color: red;
		font-size: 2em;
		font-family: 'Comic Sans MS';
	}
</style>
```

`.foo` should be preserved; it isn't.


Discussion:

Patch:
diff --git a/src/css/Selector.ts b/src/css/Selector.ts
--- a/src/css/Selector.ts
+++ b/src/css/Selector.ts
@@ -223,6 +223,9 @@ const operators = {
 };
 
 function attributeMatches(node: Node, name: string, expectedValue: string, operator: string, caseInsensitive: boolean) {
+	const spread = node.attributes.find(attr => attr.type === 'Spread');
+	if (spread) return true;
+
 	const attr = node.attributes.find((attr: Node) => attr.name === name);
 	if (!attr) return false;
 	if (attr.value === true) return operator === null;


Test patch:
diff --git a/test/css/samples/spread/_config.js b/test/css/samples/spread/_config.js
new file mode 100644
--- /dev/null
+++ b/test/css/samples/spread/_config.js
@@ -0,0 +1,3 @@
+export default {
+	cascade: false
+};
\ No newline at end of file
diff --git a/test/css/samples/spread/expected.css b/test/css/samples/spread/expected.css
new file mode 100644
--- /dev/null
+++ b/test/css/samples/spread/expected.css
@@ -0,0 +1 @@
+.foo.svelte-xyz{color:red;font-size:2em;font-family:'Comic Sans MS'}
\ No newline at end of file
diff --git a/test/css/samples/spread/input.html b/test/css/samples/spread/input.html
new file mode 100644
--- /dev/null
+++ b/test/css/samples/spread/input.html
@@ -0,0 +1,11 @@
+<div {{...props}} >
+	Big red Comic Sans
+</div>
+
+<style>
+	.foo {
+		color: red;
+		font-size: 2em;
+		font-family: 'Comic Sans MS';
+	}
+</style>
\ No newline at end of file