From 12a088b1caa0d0187948a82be71a265c8221a552 Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Tue, 17 Jan 2017 14:14:33 -0500 Subject: [PATCH] handle multiline comments in CSS - fixes #252 --- src/generators/shared/css/transform.js | 2 +- test/generator/css-comments/_config.js | 7 +++++++ test/generator/css-comments/main.html | 11 +++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 test/generator/css-comments/_config.js create mode 100644 test/generator/css-comments/main.html diff --git a/src/generators/shared/css/transform.js b/src/generators/shared/css/transform.js index 803c16d47adf..12ae0981e58f 100644 --- a/src/generators/shared/css/transform.js +++ b/src/generators/shared/css/transform.js @@ -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+%)/; diff --git a/test/generator/css-comments/_config.js b/test/generator/css-comments/_config.js new file mode 100644 index 000000000000..f6235d06a20d --- /dev/null +++ b/test/generator/css-comments/_config.js @@ -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' ); + } +}; diff --git a/test/generator/css-comments/main.html b/test/generator/css-comments/main.html new file mode 100644 index 000000000000..68eebfdf38b7 --- /dev/null +++ b/test/generator/css-comments/main.html @@ -0,0 +1,11 @@ +

red

+ +