Skip to content

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