-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Failing to collect selectors with declaration that only has custom properties #331
Comments
Found a workaround. This is breaking not because of the selector but all the properties inside of the call are variables. I guess somewhere in the stack when the input is empty it doesn't count them. This hack fixes the issue though: test_hack.css[data-attribute] {
color: var(--color-foo);
}
:root,
[data-attribute="foo"] {
--color-foo: #000;
/* bar */
} output{
"size": 82,
"gzipSize": 85,
"humanizedSize": "82B",
"humanizedGzipSize": "85B",
"rules": {
"total": 2,
"size": {
"graph": [
1,
0
],
"max": 1,
"average": 0.5
},
"selectorByRuleSizes": [
{
"selector": "[data-attribute]",
"declarations": 1
},
{
"selector": ":root,\n[data-attribute=\"foo\"]",
"declarations": 0
}
]
},
"selectors": {
"total": 3,
"type": 0,
"class": 0,
"id": 0,
"pseudoClass": 1,
"pseudoElement": 0,
"values": [
"[data-attribute]",
":root",
"[data-attribute=\"foo\"]"
],
"specificity": {
"max": 10,
"average": 10
}
},
"declarations": {
"total": 1,
"unique": 1,
"uniqueToTotalRatio": 1,
"properties": {
"color": [
"#000"
]
}
},
"mediaQueries": {
"total": 0,
"unique": 0,
"values": [],
"contents": []
}
} |
Thanks for the detailed response! I'm guessing this has to do with custom property handling. That plugin runs before our stats aggregation so rulesets end up empty and are ignored or potentially even removed. |
We knew custom property resolution would be a breaking change, hence the major version, but this is indeed buggy behavior we should fix. |
I'm not exactly sure what's incorrect but given these inputs, I'm not finding the css grouping that includes
:root,[data-attribute="foo"]
oncssstats v4.0.2
This started happening when I upgraded from 3.3.0 to 4.0.2test.css
cli command
output
The text was updated successfully, but these errors were encountered: