mirror of
https://github.com/sveltejs/svelte.git
synced 2024-11-29 16:36:44 +01:00
Merge pull request #796 from sveltejs/gh-757
handle css vars in <style> tags
This commit is contained in:
commit
0efa2ac7d7
@ -135,10 +135,15 @@ class Declaration {
|
||||
|
||||
minify(code: MagicString) {
|
||||
const c = this.node.start + this.node.property.length;
|
||||
const first = this.node.value.children[0];
|
||||
const first = this.node.value.children ?
|
||||
this.node.value.children[0] :
|
||||
this.node.value;
|
||||
|
||||
if (first.start - c > 1) {
|
||||
code.overwrite(c, first.start, ':');
|
||||
let start = first.start;
|
||||
while (/\s/.test(code.original[start])) start += 1;
|
||||
|
||||
if (start - c > 1) {
|
||||
code.overwrite(c, start, ':');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
1
test/css/samples/css-vars/expected.css
Normal file
1
test/css/samples/css-vars/expected.css
Normal file
@ -0,0 +1 @@
|
||||
div[svelte-xyz],[svelte-xyz] div{--test:10}
|
7
test/css/samples/css-vars/input.html
Normal file
7
test/css/samples/css-vars/input.html
Normal file
@ -0,0 +1,7 @@
|
||||
<div></div>
|
||||
|
||||
<style>
|
||||
div {
|
||||
--test: 10;
|
||||
}
|
||||
</style>
|
Loading…
Reference in New Issue
Block a user