Handle empty classes when pruning unused styles - fixes #997

pull/1004/head
Rich Harris 7 years ago committed by GitHub
parent 0be3211c4f
commit 36718e79bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -229,6 +229,7 @@ function attributeMatches(node: Node, name: string, expectedValue: string, opera
const pattern = operators[operator](expectedValue, caseInsensitive ? 'i' : ''); const pattern = operators[operator](expectedValue, caseInsensitive ? 'i' : '');
const value = attr.value[0]; const value = attr.value[0];
if (!value) return false;
if (value.type === 'Text') return pattern.test(value.data); if (value.type === 'Text') return pattern.test(value.data);
const possibleValues = new Set(); const possibleValues = new Set();

@ -0,0 +1,20 @@
export default {
cascade: false,
warnings: [{
filename: "SvelteComponent.html",
message: "Unused CSS selector",
loc: {
line: 4,
column: 1
},
pos: 31,
frame: `
2:
3: <style>
4: .x {
^
5: color: red;
6: }`
}]
};

@ -0,0 +1,7 @@
<div class=""></div>
<style>
.x {
color: red;
}
</style>
Loading…
Cancel
Save