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

Fix: :root no longer causes invalid selectors #13325

merged 1 commit into from Jan 22, 2019


None yet
4 participants
Copy link

cornedor commented Jan 15, 2019


The :root selector caused invalid selectors because the namespace was added before it. This PR handles :root the same way as html and body are handled. This is useful for defined css variables. For example:

:root {
	--color-primary: #FF0;

will now become:

.editor-styles-wrapper {
	--color-primary: #FF0;

How has this been tested?

I've build a test case and ran the tests


Types of changes

This is a bug fix. Without this PR :root will be ignored by the browser.


  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.

@gziolo gziolo requested a review from youknowriad Jan 22, 2019

Copy link

youknowriad left a comment

Seems reasonable to me. Thoughts @jasmussen

@youknowriad youknowriad added this to the 5.0 (Gutenberg) milestone Jan 22, 2019


This comment has been minimized.

Copy link

jasmussen commented Jan 22, 2019

Seems reasonable to me as well. I've very rarely used :root, but the use case seems okay to me.

Can we think of any situations where a web developer might not want :root to be rewritten?


This comment has been minimized.

Copy link
Contributor Author

cornedor commented Jan 22, 2019

:root might be a way to break out of the namespace, instead of replacing :root with with .editor-styles-wrapper it should not be prepended, but I think personally that it could become confusing. .editor-styles-wrapper :root is an invalid selector and does nothing.

@youknowriad youknowriad merged commit 3c38fce into WordPress:master Jan 22, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed

@cornedor cornedor deleted the cornedor:replace-root-selector branch Jan 25, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment