Skip to content

Commit 6bb523f

Browse files
committed
make verify_attr() recursive (it needs to go more than 2 levels deep for marker.line.color)
1 parent 7b15f99 commit 6bb523f

File tree

1 file changed

+2
-29
lines changed

1 file changed

+2
-29
lines changed

R/utils.R

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -496,37 +496,11 @@ verify_attr <- function(proposed, schema) {
496496
}
497497

498498
# do the same for "sub-attributes"
499-
# TODO: should this be done recursively?
500499
if (identical(role, "object")) {
501-
for (attr2 in names(proposed[[attr]])) {
502-
if (is.null(attrSchema[[attr2]])) next
503-
504-
valType2 <- tryNULL(attrSchema[[attr2]][["valType"]]) %||% ""
505-
role2 <- tryNULL(attrSchema[[attr2]][["role"]]) %||% ""
506-
arrayOK2 <- tryNULL(attrSchema[[attr2]][["arrayOk"]]) %||% FALSE
507-
isDataArray2 <- identical(valType2, "data_array")
508-
509-
if (!isDataArray2 && !arrayOK2 && !identical(role2, "object")) {
510-
proposed[[attr]][[attr2]] <- retain(proposed[[attr]][[attr2]], uniq)
511-
}
512-
513-
# ensure data_arrays of length 1 are boxed up by to_JSON()
514-
if (isDataArray2) {
515-
proposed[[attr]][[attr2]] <- i(proposed[[attr]][[attr2]])
516-
}
517-
518-
# tag 'src-able' attributes (needed for api_create())
519-
isSrcAble2 <- !is.null(schema[[attr]][[paste0(attr2, "src")]]) &&
520-
length(proposed[[attr]][[attr2]]) > 1
521-
if (isDataArray2 || isSrcAble2) {
522-
proposed[[attr]][[attr2]] <- structure(
523-
proposed[[attr]][[attr2]], apiSrc = TRUE
524-
)
525-
}
526-
527-
}
500+
proposed[[attr]] <- verify_attr(proposed[[attr]], schema[[attr]])
528501
}
529502
}
503+
530504
proposed
531505
}
532506

@@ -822,7 +796,6 @@ verify_guides <- function(p) {
822796

823797
idx <- which(isBar)
824798
for (i in seq_along(idx)) {
825-
# TODO: account for marker.line.colorbar
826799
j <- idx[[i]]
827800
bar <- p$x$data[[j]]$marker$colorbar
828801
p$x$data[[j]]$marker$colorbar$len <- bar$len %||% (1 / nGuides)

0 commit comments

Comments
 (0)