handle universal selectors

pull/689/head
Rich Harris 8 years ago
parent f485c25620
commit b72684e99c

@ -74,6 +74,7 @@ function selectorAppliesTo(parts: Node[], node: Node, stack: Node[]): boolean {
} }
else if (part.type === 'TypeSelector') { else if (part.type === 'TypeSelector') {
if (part.name === '*') return true;
if (node.name !== part.name) return false; if (node.name !== part.name) return false;
} }

@ -44,7 +44,12 @@ export default function processCss(
const child = block[i]; const child = block[i];
if (child.type === 'PseudoElementSelector' || child.type === 'PseudoClassSelector') continue; if (child.type === 'PseudoElementSelector' || child.type === 'PseudoClassSelector') continue;
if (child.type === 'TypeSelector' && child.name === '*') {
code.overwrite(child.start, child.end, attr);
} else {
code.appendLeft(child.end, attr); code.appendLeft(child.end, attr);
}
return; return;
} }
} }
@ -64,7 +69,7 @@ export default function processCss(
if (firstToken.type === 'TypeSelector') { if (firstToken.type === 'TypeSelector') {
const insert = firstToken.end - offset; const insert = firstToken.end - offset;
const head = css.slice(start, insert); const head = firstToken.name === '*' ? css.slice(firstToken.end - offset, insert) : css.slice(start, insert);
const tail = css.slice(insert, end); const tail = css.slice(insert, end);
transformed = `${head}${attr}${tail}, ${attr} ${selectorString}`; transformed = `${head}${attr}${tail}, ${attr} ${selectorString}`;

@ -0,0 +1,3 @@
export default {
cascade: false
};

@ -0,0 +1,7 @@
<div></div>
<style>
* {
color: red;
}
</style>

@ -0,0 +1,4 @@
[svelte-2950902288], [svelte-2950902288] * {
color: red;
}

@ -0,0 +1,7 @@
<div></div>
<style>
* {
color: red;
}
</style>
Loading…
Cancel
Save