File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 13
13
import plotly .io as pio
14
14
from plotly .offline import get_plotlyjs
15
15
from plotly .io ._utils import plotly_cdn_url
16
+ from plotly .io ._html import _generate_sri_hash
16
17
17
18
if sys .version_info >= (3 , 3 ):
18
19
import unittest .mock as mock
@@ -298,12 +299,19 @@ def test_repr_html(renderer):
298
299
# id number of figure
299
300
id_html = str_html .split ('document.getElementById("' )[1 ].split ('")' )[0 ]
300
301
id_pattern = "cd462b94-79ce-42a2-887f-2650a761a144"
302
+
303
+ # Calculate the SRI hash dynamically
304
+ plotlyjs_content = get_plotlyjs ()
305
+ sri_hash = _generate_sri_hash (plotlyjs_content )
306
+
301
307
template = (
302
308
'<div> <script type="text/javascript">'
303
309
"window.PlotlyConfig = {MathJaxConfig: 'local'};</script>\n "
304
310
'<script charset="utf-8" src="'
305
311
+ plotly_cdn_url ()
306
- + '" integrity="sha256-oy6Be7Eh6eiQFs5M7oXuPxxm9qbJXEtTpfSI93dW16Q=" crossorigin="anonymous"></script> '
312
+ + '" integrity="'
313
+ + sri_hash
314
+ + '" crossorigin="anonymous"></script> '
307
315
'<div id="cd462b94-79ce-42a2-887f-2650a761a144" class="plotly-graph-div" '
308
316
'style="height:100%; width:100%;"></div> <script type="text/javascript">'
309
317
" window.PLOTLYENV=window.PLOTLYENV || {};"
You can’t perform that action at this time.
0 commit comments