From 314f7ad479d1df9be6c2215f1f7ba23e20dfa6ea Mon Sep 17 00:00:00 2001 From: Carson Date: Mon, 2 Oct 2023 13:57:57 -0500 Subject: [PATCH 1/6] Require dev htmltools --- DESCRIPTION | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0d6555ffb9..2537a7af11 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -79,7 +79,7 @@ Imports: jsonlite (>= 0.9.16), xtable, fontawesome (>= 0.4.0), - htmltools (>= 0.5.4), + htmltools (> 0.5.6), R6 (>= 2.0), sourcetools, later (>= 1.0.0), @@ -210,3 +210,5 @@ RdMacros: lifecycle Config/testthat/edition: 3 Config/Needs/check: shinytest2 +Remotes: + rstudio/htmltools@null-is-atomic From 8fefdd084c9c8762b0f57e475f902d6f48fe8a9c Mon Sep 17 00:00:00 2001 From: Carson Date: Mon, 2 Oct 2023 14:04:58 -0500 Subject: [PATCH 2/6] isTruthy() should check for NULL before is.atomic() --- R/utils.R | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/R/utils.R b/R/utils.R index b54484bdeb..a741afe1f5 100644 --- a/R/utils.R +++ b/R/utils.R @@ -1243,11 +1243,12 @@ isTruthy <- function(x) { if (inherits(x, 'try-error')) return(FALSE) + if (is.null(x)) + return(FALSE) + if (!is.atomic(x)) return(TRUE) - if (is.null(x)) - return(FALSE) if (length(x) == 0) return(FALSE) if (all(is.na(x))) From ee6d668f4ee134f233431e6cb91877eef92b52af Mon Sep 17 00:00:00 2001 From: Carson Date: Mon, 2 Oct 2023 14:14:27 -0500 Subject: [PATCH 3/6] Check for NULL even earlier --- R/utils.R | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/R/utils.R b/R/utils.R index a741afe1f5..d74578cbac 100644 --- a/R/utils.R +++ b/R/utils.R @@ -1240,15 +1240,12 @@ dotloop <- function(fun_, ...) { #' @param x An expression whose truthiness value we want to determine #' @export isTruthy <- function(x) { - if (inherits(x, 'try-error')) - return(FALSE) - if (is.null(x)) return(FALSE) - + if (inherits(x, 'try-error')) + return(FALSE) if (!is.atomic(x)) return(TRUE) - if (length(x) == 0) return(FALSE) if (all(is.na(x))) From f368eb4b68b89b73a6eb4e026eda4ad4de299477 Mon Sep 17 00:00:00 2001 From: Carson Date: Mon, 2 Oct 2023 14:22:25 -0500 Subject: [PATCH 4/6] Don't require latest htmltools since it's only needed for CI-based testing --- DESCRIPTION | 4 +--- tests/testthat/test-tabPanel.R | 3 +++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 2537a7af11..0d6555ffb9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -79,7 +79,7 @@ Imports: jsonlite (>= 0.9.16), xtable, fontawesome (>= 0.4.0), - htmltools (> 0.5.6), + htmltools (>= 0.5.4), R6 (>= 2.0), sourcetools, later (>= 1.0.0), @@ -210,5 +210,3 @@ RdMacros: lifecycle Config/testthat/edition: 3 Config/Needs/check: shinytest2 -Remotes: - rstudio/htmltools@null-is-atomic diff --git a/tests/testthat/test-tabPanel.R b/tests/testthat/test-tabPanel.R index f2a91eb6d8..dc6db35d27 100644 --- a/tests/testthat/test-tabPanel.R +++ b/tests/testthat/test-tabPanel.R @@ -18,6 +18,9 @@ expect_snapshot2 <- function(...) { if (getRversion() < "3.6.0") { skip("Skipping snapshots on R < 3.6 because of different RNG method") } + if (packageVersion("htmltools") <= "0.5.6") { + skip("Skipping snapshots since htmltools is 'outdated'") + } expect_snapshot(...) } From 19d191e8a618822cbd5a399b0f91f2f8e2c52cb4 Mon Sep 17 00:00:00 2001 From: Carson Date: Mon, 2 Oct 2023 14:49:44 -0500 Subject: [PATCH 5/6] Update news --- NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index 48ffc03fef..d3c7fb971f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -12,6 +12,8 @@ * Fixed #3898: `wrapFunctionLabel()` no longer throws an error if the `name` is longer than 10000 bytes. (#3903) +* On r-devel (R > 4.3.1), `isTruthy(NULL)` now returns `FALSE` (as it does with older versions of R). (#3906) + # shiny 1.7.5 ## Possibly breaking changes From 6d855adfbfc2108d5f6b41e7ff655895c7f819ad Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Mon, 2 Oct 2023 14:55:17 -0500 Subject: [PATCH 6/6] Update tests/testthat/test-tabPanel.R --- tests/testthat/test-tabPanel.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-tabPanel.R b/tests/testthat/test-tabPanel.R index dc6db35d27..03149c7cee 100644 --- a/tests/testthat/test-tabPanel.R +++ b/tests/testthat/test-tabPanel.R @@ -18,7 +18,7 @@ expect_snapshot2 <- function(...) { if (getRversion() < "3.6.0") { skip("Skipping snapshots on R < 3.6 because of different RNG method") } - if (packageVersion("htmltools") <= "0.5.6") { + if (packageVersion("htmltools") <= "0.5.6" && getRversion() > "4.3.1") { skip("Skipping snapshots since htmltools is 'outdated'") } expect_snapshot(...)