File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change 6868# ' }
6969guides <- function (... ) {
7070 args <- list2(... )
71- if (length( args ) > 0 ) {
72- if (is.list (args [[ 1 ]]) && ! is.guide( args [[ 1 ]])) args <- args [[ 1 ]]
73- args <- rename_aes( args )
71+ # If there are no guides do nothing
72+ if (length (args ) == 0 ) {
73+ return ( NULL )
7474 }
7575
76+ if (is.list(args [[1 ]]) && ! inherits(args [[1 ]], " guide" )) args <- args [[1 ]]
77+ args <- rename_aes(args )
78+
7679 idx_false <- vapply(args , isFALSE , FUN.VALUE = logical (1L ))
7780 if (isTRUE(any(idx_false ))) {
7881 deprecate_warn0(" 3.3.4" , " guides(`<scale>` = 'cannot be `FALSE`. Use \" none\" instead')" )
@@ -84,11 +87,6 @@ guides <- function(...) {
8487 return (guides_list(guides = args ))
8588 }
8689
87- # If there are no guides, do nothing
88- if (length(args ) == 0 ) {
89- return (NULL )
90- }
91-
9290 # Raise warning about unnamed guides
9391 nms <- names(args )
9492 if (is.null(nms )) {
Original file line number Diff line number Diff line change @@ -577,12 +577,16 @@ test_that("old S3 guides can be implemented", {
577577
578578 withr :: local_environment(my_env )
579579
580+ my_guides <- guides(x = guide_circle())
581+ expect_length(my_guides $ guides , 1 )
582+ expect_s3_class(my_guides $ guides [[1 ]], " guide" )
583+
580584 expect_snapshot_warning(
581585 expect_doppelganger(
582586 " old S3 guide drawing a circle" ,
583587 ggplot(mtcars , aes(disp , mpg )) +
584588 geom_point() +
585- guides( x = " circle " )
589+ my_guides
586590 )
587591 )
588592})
You can’t perform that action at this time.
0 commit comments