From bdb34a243c5241045fc4e6a12e3426fe74f4d54d Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 3 Aug 2017 22:32:27 -0400 Subject: [PATCH] avoid string manipulation bugs by not minifying combinators if cascade: true (#743) --- src/css/Stylesheet.ts | 2 +- test/css/samples/combinator-child/_config.js | 3 +++ test/css/samples/combinator-child/expected.css | 1 + test/css/samples/combinator-child/expected.html | 1 + test/css/samples/combinator-child/input.html | 11 +++++++++++ 5 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 test/css/samples/combinator-child/_config.js create mode 100644 test/css/samples/combinator-child/expected.css create mode 100644 test/css/samples/combinator-child/expected.html create mode 100644 test/css/samples/combinator-child/input.html diff --git a/src/css/Stylesheet.ts b/src/css/Stylesheet.ts index d0fcd10b70..5680ec4551 100644 --- a/src/css/Stylesheet.ts +++ b/src/css/Stylesheet.ts @@ -39,7 +39,7 @@ class Rule { code.overwrite(c, selector.node.start, separator); } - selector.minify(code); + if (!cascade) selector.minify(code); c = selector.node.end; } }); diff --git a/test/css/samples/combinator-child/_config.js b/test/css/samples/combinator-child/_config.js new file mode 100644 index 0000000000..b37866f9b6 --- /dev/null +++ b/test/css/samples/combinator-child/_config.js @@ -0,0 +1,3 @@ +export default { + cascade: false +}; \ No newline at end of file diff --git a/test/css/samples/combinator-child/expected.css b/test/css/samples/combinator-child/expected.css new file mode 100644 index 0000000000..3f2c64212e --- /dev/null +++ b/test/css/samples/combinator-child/expected.css @@ -0,0 +1 @@ +.test[svelte-xyz]>div[svelte-xyz]{color:#0af} \ No newline at end of file diff --git a/test/css/samples/combinator-child/expected.html b/test/css/samples/combinator-child/expected.html new file mode 100644 index 0000000000..c726b2b537 --- /dev/null +++ b/test/css/samples/combinator-child/expected.html @@ -0,0 +1 @@ +
Testing...
\ No newline at end of file diff --git a/test/css/samples/combinator-child/input.html b/test/css/samples/combinator-child/input.html new file mode 100644 index 0000000000..90e8fbe488 --- /dev/null +++ b/test/css/samples/combinator-child/input.html @@ -0,0 +1,11 @@ +
+
+ Testing... +
+
+ +