mirror of
https://github.com/rstudio/shiny.git
synced 2026-04-07 03:00:20 -04:00
Make sure test values are named vectors
This commit is contained in:
@@ -640,6 +640,13 @@ ShinySession <- R6Class(
|
||||
}
|
||||
}
|
||||
|
||||
# Make sure inputs, outputs, exports are all named lists (at this
|
||||
# point, they could be unnamed if they are empty lists). This is so
|
||||
# that the resulting object is represented as an object in JSON
|
||||
# instead of an array, and so that the RDS data structure is of a
|
||||
# consistent type.
|
||||
values <- lapply(values, asNamedVector)
|
||||
|
||||
if (length(values) == 0) {
|
||||
return(httpResponse(400, "text/plain",
|
||||
"No exports, inputs, or outputs requested."
|
||||
|
||||
10
R/utils.R
10
R/utils.R
@@ -182,6 +182,16 @@ anyUnnamed <- function(x) {
|
||||
any(!nzchar(nms))
|
||||
}
|
||||
|
||||
|
||||
# Given a vector/list, returns a named vector (the labels will be blank).
|
||||
asNamedVector <- function(x) {
|
||||
if (!is.null(names(x)))
|
||||
return(x)
|
||||
|
||||
names(x) <- rep.int("", length(x))
|
||||
x
|
||||
}
|
||||
|
||||
# Given two named vectors, join them together, and keep only the last element
|
||||
# with a given name in the resulting vector. If b has any elements with the same
|
||||
# name as elements in a, the element in a is dropped. Also, if there are any
|
||||
|
||||
Reference in New Issue
Block a user