@@ -424,6 +424,15 @@ as_widget <- function(x, ...) {
424
424
),
425
425
preRenderHook = plotly_build ,
426
426
dependencies = c(
427
+ # phantomjs doesn't support Object.setPrototypeOf() and a
428
+ # plotly.js dependency (buffer) uses it to detect TypedArray support.
429
+ # Thus, we add a polyfill if this is running in shinytest, but otherwise
430
+ # we shouldn't need it because Object.setPrototypeOf() is pretty widely supported
431
+ # https://github.com/plotly/plotly.js/issues/4556#issuecomment-583061419
432
+ # https://caniuse.com/#search=setPrototypeOf
433
+ if (isTRUE(getOption(" shiny.testmode" ))) {
434
+ list (setPrototypeOfPolyfill())
435
+ },
427
436
list (typedArrayPolyfill()),
428
437
crosstalk :: crosstalkLibs(),
429
438
list (plotlyHtmlwidgetsCSS()),
@@ -432,6 +441,17 @@ as_widget <- function(x, ...) {
432
441
)
433
442
}
434
443
444
+ setPrototypeOfPolyfill <- function () {
445
+ htmltools :: htmlDependency(
446
+ name = " setprototypeof" ,
447
+ version = " 0.1" ,
448
+ package = " plotly" ,
449
+ src = dependency_dir(" setprototypeof" ),
450
+ script = " setprototypeof.js" ,
451
+ all_files = FALSE
452
+ )
453
+ }
454
+
435
455
typedArrayPolyfill <- function () {
436
456
htmltools :: htmlDependency(
437
457
name = " typedarray" ,
0 commit comments