-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Another take on implementing CSS variables (custom properties) #3314
Conversation
Funny how the tests do pass on my local machine :/ |
CI failed with undefined index notices on PHP 7.3, here’s the output: There were 6 errors
When running locally on PHP 8.2, I get several deprecation notices (need to pass |
Approved running the tests so you can see any failures as you make updates. |
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.
Some initial thoughts for discussion. I haven't thoroughly evaluated this in relation to the spec nor in relation to how we generally parse CSS properties.
Awsome, those 3 tests fail locally as well because the border shorthand property is never running |
Thanks for all the reviews, but I am getting the feeling that the different conversations are getting mixed (and duplicated). So I am struggling to keep up...
Feel free to commit what you have, I believe you have the required permissions. I don't want to break anything of your work in an attempt to close some of the above threads. |
Yes, I noticed that. My apologies. I dunno what happened I think I somehow started a new review when I was commenting on another thread. And then I made a similar comment twice. 😞
I'll make those changes and resolve a few conversations. |
dbff59f
to
9a52a8b
Compare
OK I've added changes that handle recursion plus improve variable resolution dependency. @Neograph734 you'll want to re-clone or hard reset your local repo since I rewrote the history to avoid potential complications with merging (after I royally flubbed it earlier). The dependency logic is kinda kludgey, but I was having trouble finding a better way to handle it. I have a vague idea about how to improve the dependency handling in set_prop but I don't think I'm able to sufficiently articulate it right now. Plus the direction I'm thinking would require a change to the internal structure of the Style class related to specified properties. I added some test cases to cover some scenarios that weren't working previously. The document I was using to test things follows. sample document
|
…been updated. Border tests still fail because the shorthand values are never computed and parse_var() is never called.
I have just implemented this in my development environment. This obviously contains much more CSS than the test cases, but I must say that it appears to work quite good. My color variables all neatly resolve. Thanks for giving this the last push Brian! By the way, I cannot find that last requested change that github is complaining about... |
Glad it's working well for you as well. I think that change request is just because I haven't updated my review so it's still reporting that I have requested changes. I added an approval review to make that go away. I have some other things I need to work on so I'll let this incubate a little longer in case anybody else has suggestions. |
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.
Don’t have the time for a full review currently, so just some minor review comments for now.
- fixes important property check - improves handling of important properties with regard to variable resolution - improves unset and initial keyword handling for variables
I was wondering, we have introduced a lot of different variants of:
I am tempted to create a regex pattern for it, to bring it more in line with the rest of the code. At the same time I always learned that regex is slow. I am not sure if performance or code readbility is more important here. A small Similarly, on line 1559 of Style.php we might want to use the |
Performance is always top of mind, but I think we're safe adding a wrapper function to improve maintainability. I would expect that would be a compiler optimizable call.
Yes, that makes sense. We should use consistent logic to ensure that the code is more maintainable. |
I think we're brought this far enough, though I'm sure we could continue to optimize. I'll merge next week if no further updates or feedback are forthcoming. |
Great news, much appreciated! |
I have always thought this would be difficult because of the time #1872 is already open, but thanks tmolitor-stud-tu for showing how easy it actually is in #3255.
The approach there was a great start, but it was missing the possibility to use fallback values as a second parameter of var(). Furthermore I have shuffled some assignments around and wrote tests. Please share your thoughts.