Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

S3method("$",ggproto)
S3method("$",ggproto_parent)
S3method("$",theme)
S3method("$<-",uneval)
S3method("+",gg)
S3method("[",mapped_discrete)
Expand Down
3 changes: 3 additions & 0 deletions R/theme.R
Original file line number Diff line number Diff line change
Expand Up @@ -804,5 +804,8 @@ is.subclass <- function(x, y) {
#' @keywords internal
is.theme <- function(x) inherits(x, "theme")

#' @export
`$.theme` <- .subset2

Comment thread
teunbrand marked this conversation as resolved.
#' @export
print.theme <- function(x, ...) utils::str(x)
6 changes: 6 additions & 0 deletions tests/testthat/test-theme.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
skip_on_cran() # This test suite is long-running (on cran) and is skipped

test_that("dollar subsetting the theme does no partial matching", {
t <- theme(foobar = 12)
expect_null(t$foo)
expect_equal(t$foobar, 12)
})

test_that("modifying theme element properties with + operator works", {

# Changing a "leaf node" works
Expand Down