Open erwanvivien opened 2 weeks ago
Sorry I deleted my original comment. What exactly is broken here, there is no [data-active='true']
only [data-active='false']
?
This is not a boolean attribute so the value is stringified.
If a variable is used for the data attribute then the css is good. Not sure how intentional this is but it makes sense to me as the css parser seems to be quite literal about the hard-coded values.
I too do not fully understand what you're trying to show here. If the variable is false, then it's ok that it's marked as unused? Or is it about the weird discrepancy of one being marked as used and the other not?
I don't know what the false as true
is supposed to do, but it does seem weird that the as true
affects the scoping.
To me, the issue is that the first one isn't recognized as unused, not that the second one is.
Thanks everyone for the comments
@Conduitry said
To me, the issue is that the first one isn't recognized as unused, not that the second one is.
Which is what I kinda want to point out, I would indeed skip the as true
when checking the literal values (meaning trusting values instead of typing)
At the end we'd have two unused CSS selector
I had this use case (which I changed later to using a state variable) but meanwhile I had this inner component using the old DOM API to add and remove data-attributes
which meant I didn't care about the initial value
I dug into this and it turns out that this goes back to our TS stripping algorithm not working correctly. While it removes the TS nodes, the parent
and prev
nodes become out of date - they point to the old nodes prior to stripping. This goes back to zimmerframe
automatically creating new objects where needed so everything stays immutable.
The most pragmatic solution IMO is to allow zimmerframe to mutate the AST instead, which solves this issue.
I've added comments on the zimmerframe PR
My guts are telling me that mutating things is usually not the right way of doing things though
Describe the bug
I think we should relax the CSS verification for attributes
In my code I had to add
data-active={false as true}
to not trigger the first CSS selector Then I added the second CSS selector, but this one is not correctly picked upReproduction
REPL
Logs
No response
System Info
Severity
annoyance