mirror of
https://github.com/rstudio/shiny.git
synced 2026-04-07 03:00:20 -04:00
handle no-argument output calls gracefully
This commit is contained in:
10
R/shiny.R
10
R/shiny.R
@@ -602,8 +602,14 @@ ShinySession <- setRefClass(
|
||||
#' @S3method $<- shinyoutput
|
||||
`$<-.shinyoutput` <- function(x, name, value) {
|
||||
label <- deparse(substitute(value))
|
||||
attr(label, "srcref") <- srcrefFromShinyCall(substitute(value)[[2]])
|
||||
attr(label, "srcfile") <- srcFileOfRef(attr(substitute(value)[[2]], "srcref")[[1]])
|
||||
if (length(substitute(value)) > 1) {
|
||||
# value is an object consisting of a call and its arguments. Here we want
|
||||
# to find the source references for the first argument (if there are
|
||||
# arguments), which generally corresponds to the reactive expression--
|
||||
# e.g. in renderTable({ x }), { x } is the expression to trace.
|
||||
attr(label, "srcref") <- srcrefFromShinyCall(substitute(value)[[2]])
|
||||
attr(label, "srcfile") <- srcFileOfRef(attr(substitute(value)[[2]], "srcref")[[1]])
|
||||
}
|
||||
.subset2(x, 'impl')$defineOutput(name, value, label)
|
||||
return(invisible(x))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user