Skip to content

Commit a76d1ab

Browse files
committed
allow unregistered geom.* elements in theme
1 parent efc53cc commit a76d1ab

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

R/theme.R

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,8 +565,11 @@ validate_theme <- function(theme, tree = get_element_tree(), call = caller_env()
565565
if (!is_theme_validate(theme)) {
566566
return()
567567
}
568+
elnames <- names(theme)
569+
elnames[startsWith(elnames, "geom.")] <- "geom"
570+
568571
mapply(
569-
validate_element, theme, names(theme),
572+
validate_element, theme, elnames,
570573
MoreArgs = list(element_tree = tree, call = call)
571574
)
572575
}
@@ -630,7 +633,10 @@ plot_theme <- function(x, default = get_theme()) {
630633
validate_theme(theme)
631634

632635
# Remove elements that are not registered
633-
theme[setdiff(names(theme), names(get_element_tree()))] <- NULL
636+
# We accept unregistered `geom.*` elements
637+
remove <- setdiff(names(theme), names(get_element_tree()))
638+
remove <- remove[!startsWith(remove, "geom.")]
639+
theme[remove] <- NULL
634640
theme
635641
}
636642

0 commit comments

Comments
 (0)