-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Additional CSS: Add code comments contextualising tranformStyles for clarity #60267
Additional CSS: Add code comments contextualising tranformStyles for clarity #60267
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: +4 B (0%) Total Size: 1.72 MB
ℹ️ View Unchanged
|
@@ -28,6 +28,10 @@ export default function AdvancedPanel( { | |||
css: newValue, | |||
} ); | |||
if ( cssError ) { | |||
// Pass a wrapping selector to transformStyles to ensure that the CSS | |||
// tested resembles actual CSS rules. This is necessary because the additional CSS | |||
// field supports CSS rules that are not wrapped in a selector. |
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.
To be precise, we need to pass a wrapper selector because otherwise the transformStyle function will return before it does the error checking. I don't think it really matters whether the actual CSS is a whole rule or just a property or two. Afaict inputting a single property will output the same (unwrapped) property, whether we pass a wrapper or not.
It would probably be better to have a dedicated error checking function instead of using this one 🤔 That might be a good improvement to add to the list for additional CSS!
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.
Thanks for following up on this @andrewserong 👍
As these comments note, the selector is only for validation purposes. I think we could make this obvious by replacing .editor-styles-wrapper
here with something like .for-validation-only
.
What do you think?
… classname will not be used in output
c376976
to
a2a6465
Compare
Thanks for the feedback and good ideas, folks! I've updated the classname strings to |
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.
Thanks for the quick tweaks 🚀
LGTM 🚢
…clarity (WordPress#60267) * Additional CSS: Add code comments contextualising tranformStyles for clarity * Simplify comments, use a classname that more obviously flags that the classname will not be used in output Co-authored-by: andrewserong <andrewserong@git.wordpress.org> Co-authored-by: tellthemachines <isabel_brison@git.wordpress.org> Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
What?
In the AdvancedPanel for Additional CSS, add a couple of code comments clarifying that what looks like the styles being transform is actually just a transformation being used for validation only, it does not transform any of the styling rules that will be output.
Why?
While reviewing #56649, a few of us were tripped up by these lines. As described in this comment (#56649 (comment)) the reviewers got to the bottom of it, but I believe it'd help to add some code comments here for clarity, and to hopefully avoid confusion further down the track.
How?
Testing Instructions
asdf
, example legal CSS:border: 1px solid;
Testing Instructions for Keyboard
Screenshots or screencast