Skip to content

Prevent iplot from breaking when Jupyter notebook has headline named "Plotly" #1250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions plotly/offline/offline.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ def init_notebook_mode(connected=False):
# Note we omit the extension .js because require will include it.
'\'plotly\': [\'https://cdn.plot.ly/plotly-latest.min\']}},'
'}});'
'if(!window.Plotly) {{'
'if(!window._Plotly) {{'
'require([\'plotly\'],'
'function(plotly) {{window.Plotly=plotly;}});'
'function(plotly) {{window._Plotly=plotly;}});'
'}}'
'</script>'
).format(win_config=_window_plotly_config,
Expand All @@ -217,12 +217,12 @@ def init_notebook_mode(connected=False):
'{win_config}'
'{mathjax_config}'
'<script type=\'text/javascript\'>'
'if(!window.Plotly){{'
'if(!window._Plotly){{'
'define(\'plotly\', function(require, exports, module) {{'
'{script}'
'}});'
'require([\'plotly\'], function(Plotly) {{'
'window.Plotly = Plotly;'
'window._Plotly = Plotly;'
'}});'
'}}'
'</script>'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test('should inject raw plotly.js code into DOM', function(t) {
nodes = Array.prototype.slice.call(nodes, 0, 10);

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

t.equal(results.length, 1);
Expand Down