Skip to content

Commit

Permalink
Merge pull request #1310 from sveltejs/gh-1300
Browse files Browse the repository at this point in the history
bail out of CSS optimisations on encountering spread
  • Loading branch information
Rich-Harris authored Apr 4, 2018
2 parents 58dba84 + d6b8ca3 commit 8717ff8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/css/Selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions test/css/samples/spread/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
cascade: false
};
1 change: 1 addition & 0 deletions test/css/samples/spread/expected.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.foo.svelte-xyz{color:red;font-size:2em;font-family:'Comic Sans MS'}
11 changes: 11 additions & 0 deletions test/css/samples/spread/input.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div {{...props}} >
Big red Comic Sans
</div>

<style>
.foo {
color: red;
font-size: 2em;
font-family: 'Comic Sans MS';
}
</style>

0 comments on commit 8717ff8

Please sign in to comment.