Skip to content

Commit b0a4add

Browse files
committed
Include setPrototype polyfill in non-HTML output formats, closes #1702
1 parent 3283da6 commit b0a4add

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

NEWS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ This is minor patch release with a few minor bug fixes and updates test expectat
44

55
## BUG FIXES
66

7-
* `plot_mapbox()` now correctly defaults to a scattermapbox trace (unless z is present, then it defaults to choroplethmapbox) (#1702).
7+
* Fixes rendering issues non-HTML **rmarkdown** output formats, which was introduced in the 4.9.2 release (#1702).
8+
* `plot_mapbox()` now correctly defaults to a scattermapbox trace (unless z is present, then it defaults to choroplethmapbox) (#1707).
89
* `ggplotly()` now correctly resolves overlapping axis tick text in `coord_sf()` (#1673).
910
* A false-positive warning is no longer thrown when attempting to cast `toWebGL()` (#1569).
1011

R/plotly.R

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ as_widget <- function(x, ...) {
430430
# we shouldn't need it because Object.setPrototypeOf() is pretty widely supported
431431
# https://github.com/plotly/plotly.js/issues/4556#issuecomment-583061419
432432
# https://caniuse.com/#search=setPrototypeOf
433-
if (isTRUE(getOption("shiny.testmode"))) {
433+
if (needsPrototypePolyfill()) {
434434
list(setPrototypeOfPolyfill())
435435
},
436436
list(typedArrayPolyfill()),
@@ -441,6 +441,18 @@ as_widget <- function(x, ...) {
441441
)
442442
}
443443

444+
needsPrototypePolyfill <- function() {
445+
if (isTRUE(getOption("shiny.testmode"))) {
446+
return(TRUE)
447+
}
448+
449+
if (isTRUE(getOption("knitr.in.progress"))) {
450+
return(!knitr::is_html_output())
451+
}
452+
453+
return(FALSE)
454+
}
455+
444456
setPrototypeOfPolyfill <- function() {
445457
htmltools::htmlDependency(
446458
name = "setprototypeof",

0 commit comments

Comments
 (0)