You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running this htmlwidget within an iframe causes some odd behaviour.
When trying to update the widget's data via renderValue from the parent frame I get this error:
SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse (<anonymous>)
at new TraceManager (plotly-c1d49eded87001936f93debf9b25b2d0.js:551)
at Object.renderValue (plotly-c1d49eded87001936f93debf9b25b2d0.js:389)
(this is because we are trying to deserialize graphDiv.data which is undefined)
Because the widget is in an iframe, the parent's Object.prototype is different from the iframe's Object.prototype.
I see there's been discussion on changing this implementation on the plotly repo: plotly/plotly.js#1405
but there's little momentum. I propose we can fix it within the widget's js by replacing the object's prototype object if we detect that we're running in an iframe
The text was updated successfully, but these errors were encountered:
Running this htmlwidget within an iframe causes some odd behaviour.
When trying to update the widget's data via renderValue from the parent frame I get this error:
Im running these widgets in a pretty specific environment, the underlying cause is simple but setting it up is not.
I've tried to keep it simple with this pen: https://codepen.io/jefshe/pen/aPvGpO
Basically the pen is showing the htmlwidget embedded within an iframe. When clicking the button the javascript code tries to update the widget by calling renderValue (with the exact same data in this scenario but a more useful scenario would be when we want to alter something about the data). This leads to the error that I've mentioned
Hmm, that codepen doesn't seem like a great idea. That code is relying pretty heavily on code internal to plotly and htmlwidgets. Have you considered an approach like #1441 (comment)?
Running this htmlwidget within an iframe causes some odd behaviour.
When trying to update the widget's data via renderValue from the parent frame I get this error:
(this is because we are trying to deserialize
graphDiv.data
which is undefined)I've tracked this problem down to plotly's
isPlainObject
implementation which checks if the object's prototype isObject.prototype
:https://github.com/plotly/plotly.js/blob/master/src/lib/is_plain_object.js#L25
Because the widget is in an iframe, the parent's
Object.prototype
is different from the iframe'sObject.prototype
.I see there's been discussion on changing this implementation on the plotly repo:
plotly/plotly.js#1405
but there's little momentum. I propose we can fix it within the widget's js by replacing the object's prototype object if we detect that we're running in an iframe
The text was updated successfully, but these errors were encountered: