Skip to content

Commit

Permalink
Merge pull request #254 from sveltejs/gh-252
Browse files Browse the repository at this point in the history
handle multiline comments in CSS
  • Loading branch information
Rich-Harris committed Jan 17, 2017
2 parents d5648df + 12a088b commit 8814460
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/generators/shared/css/transform.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// largely borrowed from Ractive – https://github.com/ractivejs/ractive/blob/2ec648aaf5296bb88c21812e947e0e42fcc456e3/src/Ractive/config/custom/css/transform.js
const selectorsPattern = /(?:^|\})?\s*([^\{\}]+)\s*\{/g;
const commentsPattern = /\/\*.*?\*\//g;
const commentsPattern = /\/\*[\s\S]*?\*\//g;
const selectorUnitPattern = /((?:(?:\[[^\]+]\])|(?:[^\s\+\>~:]))+)((?:::?[^\s\+\>\~\(:]+(?:\([^\)]+\))?)*\s*[\s\+\>\~]?)\s*/g;
const excludePattern = /^(?:@|\d+%)/;

Expand Down
7 changes: 7 additions & 0 deletions test/generator/css-comments/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// JSDOM makes this test pass when it should fail. weird
export default {
test ( assert, component, target, window ) {
const p = target.querySelector( 'p' );
assert.equal( window.getComputedStyle( p ).color, 'red' );
}
};
11 changes: 11 additions & 0 deletions test/generator/css-comments/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<p>red</p>

<style>
/*
div {}
*/

p {
color: red;
}
</style>

0 comments on commit 8814460

Please sign in to comment.