@@ -469,6 +469,26 @@ theme <- function(...,
469
469
validate = TRUE ) {
470
470
elements <- find_args(... , complete = NULL , validate = NULL )
471
471
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 ) {
472
492
if (! is.null(elements $ axis.ticks.margin )) {
473
493
deprecate_warn0(
474
494
" 2.0.0" , " theme(axis.ticks.margin)" ,
@@ -539,22 +559,7 @@ theme <- function(...,
539
559
elements $ legend.position.inside <- elements $ legend.position
540
560
elements $ legend.position <- " inside"
541
561
}
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
558
563
}
559
564
560
565
# ' @export
0 commit comments