Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(tagAppendAttributes): Improve guidance for boolean attributes #427

Merged
merged 3 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<div contenteditable></div>`. (thanks @russHyde, #427)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd lean towards not having a NEWS note, but since this is a small release, I don't mind either way

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also vacillated but added it because I thought it might increase the search surface area to figure out how to define boolean attributes.


## Bug fixes

* `bindFillRole()` now attaches its `HTMLDependency()` to fill items, thus reducing the possibility of filling layout breaking due to missing CSS. (#421)
Expand Down
5 changes: 4 additions & 1 deletion R/tags.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down
5 changes: 4 additions & 1 deletion man/tagAppendAttributes.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading