diff --git a/NEWS.md b/NEWS.md index aeec2449..d24e2b37 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,8 @@ * The fill CSS attached to fillable containers and fill items with `bindFillRole()` now uses a [CSS cascade layer](https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Cascade_layers) named `htmltools` to reduce the precedence order of the fill CSS. (#425) +* Improved documentation for boolean attributes in `tagAppendAttributes()` to note that they can be set via an `NA` value, e.g. `tagAppendAttributes(div(), contenteditable = NA)` creates `
`. (thanks @russHyde, #427) + ## Bug fixes * `bindFillRole()` now attaches its `HTMLDependency()` to fill items, thus reducing the possibility of filling layout breaking due to missing CSS. (#421) diff --git a/R/tags.R b/R/tags.R index e35691bb..2eea80f5 100644 --- a/R/tags.R +++ b/R/tags.R @@ -403,7 +403,9 @@ tagAddRenderHook <- function(tag, func, replace = FALSE) { #' #' @export #' @param tag a [tag] object. -#' @param ... a collection of attributes. +#' @param ... Attributes to append as named argument-value pairs. A named +#' argument with an `NA` value is rendered as a boolean attribute (see +#' example). #' @param .cssSelector A character string containing a [CSS #' selector](https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Selectors) #' for targeting particular (inner) tags of interest. At the moment, only a @@ -423,6 +425,7 @@ tagAddRenderHook <- function(tag, func, replace = FALSE) { #' html <- div(a()) #' tagAppendAttributes(html, class = "foo") #' tagAppendAttributes(html, .cssSelector = "a", class = "bar") +#' tagAppendAttributes(html, contenteditable = NA) #' #' tagHasAttribute(div(foo = "bar"), "foo") #' tagGetAttribute(div(foo = "bar"), "foo") diff --git a/man/tagAppendAttributes.Rd b/man/tagAppendAttributes.Rd index 0b1dc7a8..411ba88a 100644 --- a/man/tagAppendAttributes.Rd +++ b/man/tagAppendAttributes.Rd @@ -15,7 +15,9 @@ tagGetAttribute(tag, attr) \arguments{ \item{tag}{a \link{tag} object.} -\item{...}{a collection of attributes.} +\item{...}{Attributes to append as named argument-value pairs. A named +argument with an \code{NA} value is rendered as a boolean attribute (see +example).} \item{.cssSelector}{A character string containing a \href{https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Selectors}{CSS selector} for targeting particular (inner) tags of interest. At the moment, only a @@ -40,6 +42,7 @@ and obtain the value (\code{tagGetAttribute()}) of HTML attribute(s). html <- div(a()) tagAppendAttributes(html, class = "foo") tagAppendAttributes(html, .cssSelector = "a", class = "bar") +tagAppendAttributes(html, contenteditable = NA) tagHasAttribute(div(foo = "bar"), "foo") tagGetAttribute(div(foo = "bar"), "foo")