dash-dangerously-set-inner-html
dash-dangerously-set-inner-html copied to clipboard
JavaScript isn't executed
I tried this example which should show an alert-dialog with the text test. However, no dialog is displayed, neither with Firefox 65 nor with Chrome 72 Here is the code for this example
import dash_dangerously_set_inner_html
import dash
import dash_html_components as html
app = dash.Dash('')
app.scripts.config.serve_locally = True
app.layout = html.Div([
dash_dangerously_set_inner_html.DangerouslySetInnerHTML('''
<script type="text/javascript">alert('test')</script>
'''),
])
if __name__ == '__main__':
app.run_server(debug=True)
If an Iframe is used instead of dash_dangerously_set_inner_html, the dialog will appear.
import dash_dangerously_set_inner_html
import dash
import dash_html_components as html
app = dash.Dash('')
app.scripts.config.serve_locally = True
app.layout = html.Div([
html.Iframe(srcDoc='''
<script type="text/javascript">alert('test')</script>
'''),
])
if __name__ == '__main__':
app.run_server(debug=True)
Is it itentional that JavaScript isn't executed in dash_dangerously_set_inner_html or is it a bug?
Here are my package versions:
- Python: Python 3.6.8
- dash-dangerously-set-inner-html: 0.0.2
- dash-core-components: 0.43.0
- dash-html-components: 0.13.5
- dash-renderer: 0.17.0
- dash-table: 3.3.0
- flask: 1.0.2