Skip to content

Commit 11f6cd0

Browse files
committed
helper for testing for null units
1 parent ae77fab commit 11f6cd0

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

R/guides-.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ validate_guide <- function(guide) {
927927

928928
redistribute_null_units <- function(units, spacing, margin, type = "width") {
929929

930-
has_null <- vapply(units, function(x) any(unitType(x) == "null"), logical(1))
930+
has_null <- vapply(units, has_null_unit, logical(1))
931931

932932
# Early exit when we needn't bother with null units
933933
if (!any(has_null)) {

R/utilities-grid.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,7 @@ height_cm <- function(x) {
6767
cli::cli_abort("Don't know how to get height of {.cls {class(x)}} object")
6868
}
6969
}
70+
71+
has_null_unit <- function(x) {
72+
any(unlist(unitType(x, recurse = TRUE), use.names = FALSE) == "null")
73+
}

0 commit comments

Comments
 (0)