mirror of
https://github.com/rstudio/shiny.git
synced 2026-04-07 03:00:20 -04:00
Merge pull request #355 from jcheng5/bugfix/null-children
Ignore NULL tag elements
This commit is contained in:
2
R/tags.R
2
R/tags.R
@@ -126,7 +126,7 @@ tag <- function(`_tag_name`, varArgs) {
|
||||
# Unnamed arguments are flattened and added as children.
|
||||
# Use unname() to remove the names attribute from the list, which would
|
||||
# consist of empty strings anyway.
|
||||
children <- flattenTags(unname(varArgs[!named_idx]))
|
||||
children <- dropNullsOrEmpty(flattenTags(unname(varArgs[!named_idx])))
|
||||
|
||||
# Return tag data structure
|
||||
structure(
|
||||
|
||||
@@ -60,6 +60,14 @@ dropNulls <- function(x) {
|
||||
x[!vapply(x, is.null, FUN.VALUE=logical(1))]
|
||||
}
|
||||
|
||||
nullOrEmpty <- function(x) {
|
||||
is.null(x) || length(x) == 0
|
||||
}
|
||||
# Given a vector or list, drop all the NULL items in it
|
||||
dropNullsOrEmpty <- function(x) {
|
||||
x[!vapply(x, nullOrEmpty, FUN.VALUE=logical(1))]
|
||||
}
|
||||
|
||||
knownContentTypes <- Map$new()
|
||||
knownContentTypes$mset(
|
||||
html='text/html; charset=UTF-8',
|
||||
|
||||
Reference in New Issue
Block a user