Skip to content
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

Injected editor-styles invalidate :root declarations thus breaking custom properties #14297

Closed
mor10 opened this issue Mar 6, 2019 · 2 comments

Comments

@mor10
Copy link
Contributor

mor10 commented Mar 6, 2019

Describe the bug
Same issue, but different reasoning than #11955, which was closed without resolution in November 2018. The issue deserves another look and a solution as the :root pseudo-class is a core element of CSS custom properties which will see significantly increased use as browsers now provide wide-spread support:

When a theme uses CSS custom properties (aka "CSS variables") and declare those properties using the :root pseudo-class in the editor styles, the injection script invalidates those declarations by outputting .editor-styles-wrapper :root.

To Reproduce
Steps to reproduce the behavior:

  1. In editor styles document, declare CSS custom properties with :root pseudo-class.
  2. Use above custom properties in another rule.
  3. Add editor style using add_editor_style().
  4. Run in browser.
  5. Observe the declared custom properties not kicking in.
  6. Inspect code and find the :root pseudo-class has the .editor-styles-wrapper class prepended.

Expected behavior
:root pseudo-class should be preserved without alterations.

Desktop (please complete the following information):

  • OS: All
  • Browser: All with custom property support
  • Version: trunk

Additional context
See WP Rig PR #332 and issue #361 for further discussion and original discovery of the issue by @benoitchantre.

@mor10
Copy link
Contributor Author

mor10 commented Mar 6, 2019

Filed as Trac ticket as well: https://core.trac.wordpress.org/ticket/46435#ticket

@youknowriad
Copy link
Contributor

This was fixed in #13325 (will land in WP 5.2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants