-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
apply root with higher priority #14350
Conversation
I mainly reopened this given that a solution is being merged, and in testing For further reading on the treatment, MDN has a good explanation. Basic explanation: we are creating a "pseudo document", Basic use case would include defaults for style variables, set like:
Customizer dynamic typography controls override our default stylesheet:
Frontend:
Inheritance like this would mean the following:
Current implementation means that the value for .namespace could just contain using a variable, and not inherit properly from the "pseudo document" root :
So this PR seeks to resolve that with output at one point higher specificity:
Which could be inserted at any point to come before or after.
Having said all that - there's still a remaining issue of the context of html and body being treated equally when html is the root document. I think the above solution remedies most situations that are common for CSS variables, but it doesn't completely solve the namespacing issues that have cropped up. In theory - a preliminary loop over the styles could be done and things are sorted out. It would keep reference to all of the Another technique may be just removing Additional thought: There's been several people who have worked around this since release, and most solutions involve running some sort of postcss transform, find and replace, or various other things in preprocessing before distribution. It might be a nice place to have a hook so developers can modify the behavior a bit inside of the wrap process. I'm not sure if one exists or not off the top. Either way - I think this PR provides at least a partial remedy towards the problem, but everyone knows that if we were honest with ourselves, the proper solution is isolation, either via shadowroot or iframe. |
closing this since it keeps getting ignored on every release. |
I see this has finally been given attention in PR #13325 I opened an issue and pr for this before gutenberg was added to core, along with asking for review in slack a few times :(. Anyways please check out some of the information from my original PR here: #11957 Also read the original issue which overs more: #11955
The current implementation that was merged in is giving priority to
:root
the same ashtml
/body
element, but:root
needs to take precedence over those.As a way of introducing the same level specificity that
:root
has overhtml
with how the editor-style wrap is working, I think this would be a better approach. This gives.namespace:root
applied as.namespace:not(EDITOR_STYLES)
. This uses a useless negation selector to increase the specificity, which is documented in the w3 spec. Also see note at bottom of that section for useless negations.Checklist:
[ x ] My code is tested.
[ x ] My code follows the WordPress code style.
[ x ] My code follows the accessibility standards.
[ x ] My code has proper inline documentation.