-
Notifications
You must be signed in to change notification settings - Fork 193
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
Prevent simplifying translate: none;
and scale: none;
#703
Prevent simplifying translate: none;
and scale: none;
#703
Conversation
pub z: Length, | ||
pub enum Translate { | ||
/// The "none" keyword. | ||
None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also use Keyword(&'a str)
but not sure if it's worth it to do that honestly especially since keywords could all be known upfront and the 'none'
value is the only one we care about right now.
None, | ||
|
||
/// The x, y, and z translations. | ||
XYZ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could use a better name, but I don't hate it. I also noticed there are some structs like this in the colors.rs
file. E.g.: XYZd50
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks fine. Could you run yarn build-ast
to re-generate the typescript types? Technically I guess this would be a breaking AST change... Perhaps there is a way to avoid that, but lets see what it generates first.
Maybe you haven't run |
Hmm I did run yarn. Can you share which version of yarn and which version of node you are using? |
Yarn 1.22.21 |
Not sure what, but there is something wrong when trying to Funky. |
This PR fixes a subtle bug where
translate: none;
was simplified totranslate: 0;
. Similarlyscale: none;
was simplified toscale: 1;
.These simplifications are unsafe because
translate: 0;
andscale: 1;
create a stacking context wheretranslate: none;
andscale: none;
do not.The implementation currently changes the
Translate
andScale
structs to an enum with an explicitNone
variant for the"none"
case, and an explicitXYZ
variant for thex
,y
, andz
values.I considerd adding a more generic
Keyword
variant to theTranslate
andScale
enums, but I think that would be a bit overkill for this specific use case. Either way, I'm open to suggestions for the chosen APIs.Here is a jsfiddle playground (https://jsfiddle.net/2krswu8e/) to show the issue. Notice how the red boxes
5
and9
are on top of the blue boxes. This is not the case for the safetranslate: none;
andscale: none;
values.