Skip to content

Commit e4a2031

Browse files
committed
default() should use prefix_class() so that to_JSON() knows what method to use
1 parent 7372574 commit e4a2031

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

R/utils.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ is.default <- function(x) {
5050
}
5151

5252
default <- function(x) {
53-
structure(x %||% list(), class = "plotly_default")
53+
prefix_class(x %||% list(), "plotly_default")
5454
}
5555

5656
compact <- function(x) {

demo/sf-mapbox-data.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ bscols(
1717
DT::datatable(mn)
1818
)
1919

20+
# linking with plotly
2021
nc <- sf::st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE)
2122
ncsd <- SharedData$new(nc)
2223

23-
2424
# note that brushing counties is currently possible with plot_ly(), but isn't quite working
2525
# yet with plot_mapbox() -- https://github.com/plotly/plotly.js/issues/2512
2626
bscols(

tests/testthat/test-plotly-internals.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,10 @@ test_that("remove_class() can remove 'AsIs' class", {
88
x <- remove_class(I(x), "AsIs")
99
expect_equivalent(class(x), c("x", "y"))
1010
})
11+
12+
13+
test_that("default() doesn't change to_JSON() behavior", {
14+
x <- 1:10
15+
expect_equivalent(to_JSON(default(x)), to_JSON(x))
16+
})
17+

0 commit comments

Comments
 (0)