Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c935193

Browse filesBrowse files
authored
Prevent iplot from breaking when Jupyter notebook has headline named "Plotly" (plotly#1250)
This PR works around the issue where a Jupyter Notebook heading named "Plotly" clashes with the window.Plotly variable where we store the plotly.js module. The workaround is to name this variable the much less likely _Plotly
1 parent 69ec52a commit c935193
Copy full SHA for c935193

File tree

Expand file treeCollapse file tree

2 files changed

+5
-5
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+5
-5
lines changed

‎plotly/offline/offline.py

Copy file name to clipboardExpand all lines: plotly/offline/offline.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,9 @@ def init_notebook_mode(connected=False):
204204
# Note we omit the extension .js because require will include it.
205205
'\'plotly\': [\'https://cdn.plot.ly/plotly-latest.min\']}},'
206206
'}});'
207-
'if(!window.Plotly) {{'
207+
'if(!window._Plotly) {{'
208208
'require([\'plotly\'],'
209-
'function(plotly) {{window.Plotly=plotly;}});'
209+
'function(plotly) {{window._Plotly=plotly;}});'
210210
'}}'
211211
'</script>'
212212
).format(win_config=_window_plotly_config,
@@ -217,12 +217,12 @@ def init_notebook_mode(connected=False):
217217
'{win_config}'
218218
'{mathjax_config}'
219219
'<script type=\'text/javascript\'>'
220-
'if(!window.Plotly){{'
220+
'if(!window._Plotly){{'
221221
'define(\'plotly\', function(require, exports, module) {{'
222222
'{script}'
223223
'}});'
224224
'require([\'plotly\'], function(Plotly) {{'
225-
'window.Plotly = Plotly;'
225+
'window._Plotly = Plotly;'
226226
'}});'
227227
'}}'
228228
'</script>'

‎plotly/tests/test_optional/test_jupyter/js_tests/connected_false.js

Copy file name to clipboardExpand all lines: plotly/tests/test_optional/test_jupyter/js_tests/connected_false.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ test('should inject raw plotly.js code into DOM', function(t) {
2424
nodes = Array.prototype.slice.call(nodes, 0, 10);
2525

2626
var results = nodes.filter(function(node) {
27-
return node.innerHTML.substr(0, 19) === 'if(!window.Plotly){';
27+
return node.innerHTML.substr(0, 20) === 'if(!window._Plotly){';
2828
});
2929

3030
t.equal(results.length, 1);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.