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

Checks for register_theme_element(element_tree) #6169

Merged
merged 7 commits into from
Jan 27, 2025

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #6162.

Aside from throwing an error in de issue's case, I also included stricter checks on the structure of the element_tree argument.
There is the possibility this might break packages that define their own theme elements, but if so, they've been using it incorrectly.

Reprex from issue:

devtools::load_all("~/packages/ggplot2/")
#> ℹ Loading ggplot2
register_theme_elements(
  foobar = element_rect(),
  element_tree = list(foobar = el_def("element_rect", inherit = "foobar"))
)
#> Error in `register_theme_elements()`:
#> ! Invalid parent in `element_tree`: "foobar".

Created on 2024-10-29 with reprex v2.1.1

Copy link
Member

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@teunbrand teunbrand merged commit a4264bc into tidyverse:main Jan 27, 2025
4 of 13 checks passed
@teunbrand teunbrand deleted the circular_theme_registry branch January 27, 2025 13:02
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

Successfully merging this pull request may close these issues.

Circular register_theme_element() bug
2 participants