diff --git a/inst/htmlwidgets/plotly.js b/inst/htmlwidgets/plotly.js
index e693246f78..6c2bd9b3c3 100644
--- a/inst/htmlwidgets/plotly.js
+++ b/inst/htmlwidgets/plotly.js
@@ -155,6 +155,11 @@ HTMLWidgets.widget({
x.config.modeBarButtonsToRemove.push("sendDataToCloud");
}
+ // if the object was passed in from another window, plotly will falsely think it isn't a "plain object"
+ // to get around this, we do a deep clone of the object
+ if (inIframe() && !isPlainObject(x))
+ x = $.extend(true, {}, x)
+
// if no plot exists yet, create one with a particular configuration
if (!instance.plotly) {
@@ -832,6 +837,10 @@ function isPlainObject(obj) {
);
}
+function inIframe() {
+ return window && window.self !== window.top;
+}
+
function subsetArrayAttrs(obj, indices) {
var newObj = {};
Object.keys(obj).forEach(function(k) {