#56353 closed defect (bug) (fixed)
Allow assigning CSS variables in safecss_filter_attr
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 6.1 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Formatting | Keywords: | has-patch has-unit-tests add-to-field-guide |
Focuses: | Cc: |
Description
The safecss_filter_attr
allows using custom CSS variables like color: var(--color);
. However, it does not currently allow assigning values to CSS variables (like --color: #F00
) - which is something we do a lot in global-styles and Gutenberg.
We should allow assigning values to CSS variables so we can use this function consistently in Global Styles and the future Style Engine (WIP in Gutenberg)
Change History (12)
This ticket was mentioned in PR #3078 on WordPress/wordpress-develop by aristath.
3 years ago
#1
- Keywords has-patch added
This ticket was mentioned in PR #3080 on WordPress/wordpress-develop by ramonjd.
3 years ago
#3
- Keywords has-unit-tests added
A bit late. https://github.com/WordPress/wordpress-develop/pull/3078 illustrates the solution.
I'm just putting this up there to see the tests pass 😄
## Proposal
CSS custom properties don't pass the tests in safecss_filter_attr() at if ( in_array( $css_selector, $allowed_attr, true ) ) because there's no allowing entry in the allowed_attrs
array.
This is a PR to stimulate discussion around whether, and how, we WordPress could be permissive of such properties.
Trac ticket: https://core.trac.wordpress.org/ticket/56353
#4
@
3 years ago
- Keywords has-unit-tests removed
Thanks for getting this ticket open @aristath. I think it's a great opportunity to open the discussion and document the pros and cons.
Do any folks have any links to previous threads that cover this issue?
All I could find was https://core.trac.wordpress.org/ticket/46498, but there's no patch attached.
3 years ago
#6
Closing in favour of https://github.com/WordPress/wordpress-develop/pull/3078
#9
@
3 years ago
- Owner set to SergeyBiryukov
- Resolution set to fixed
- Status changed from new to closed
In 54117:
SergeyBiryukov commented on PR #3078:
3 years ago
#10
Thanks for the PR! Merged in r54117.
Trac ticket: https://core.trac.wordpress.org/ticket/56353#ticket