@@ -469,6 +469,26 @@ theme <- function(...,
469469 validate = TRUE ) {
470470 elements <- find_args(... , complete = NULL , validate = NULL )
471471
472+ elements <- fix_theme_deprecations(elements )
473+
474+ # If complete theme set all non-blank elements to inherit from blanks
475+ if (complete ) {
476+ elements <- lapply(elements , function (el ) {
477+ if (is.theme_element(el ) && ! inherits(el , " element_blank" )) {
478+ el $ inherit.blank <- TRUE
479+ }
480+ el
481+ })
482+ }
483+ structure(
484+ elements ,
485+ class = c(" theme" , " gg" ),
486+ complete = complete ,
487+ validate = validate
488+ )
489+ }
490+
491+ fix_theme_deprecations <- function (elements ) {
472492 if (! is.null(elements $ axis.ticks.margin )) {
473493 deprecate_warn0(
474494 " 2.0.0" , " theme(axis.ticks.margin)" ,
@@ -539,22 +559,7 @@ theme <- function(...,
539559 elements $ legend.position.inside <- elements $ legend.position
540560 elements $ legend.position <- " inside"
541561 }
542-
543- # If complete theme set all non-blank elements to inherit from blanks
544- if (complete ) {
545- elements <- lapply(elements , function (el ) {
546- if (is.theme_element(el ) && ! inherits(el , " element_blank" )) {
547- el $ inherit.blank <- TRUE
548- }
549- el
550- })
551- }
552- structure(
553- elements ,
554- class = c(" theme" , " gg" ),
555- complete = complete ,
556- validate = validate
557- )
562+ elements
558563}
559564
560565# ' @export
0 commit comments