Javascript is evaluated twice
A13xs opened this issue · comments
A13xs commented
Description
If I execute the following code in Notebook Classic
from typing import List
from IPython.display import Javascript, display
from ipywidgets import interactive, Box
display(Javascript('window.myGlobalVar = 0;'))
def _fnc_test():
print ("fnc_test")
display(Javascript('window.myGlobalVar++; console.log("javascript - " + window.myGlobalVar );'))
_fwidget = interactive(_fnc_test)
_layout = Box([_fwidget])
display(_layout)
The browser console display this
javascript - 1 javascript - 2
But it should show only one line
javascript - 1
Reproduce
- Create a dockerfile with this content:
FROM jupyter/base-notebook:notebook-6.4.5 AS base
RUN python -m pip install ipywidgets==8.1.1
- Run
docker build . -t myimage
- Run
docker run -p 8888:8888 myimage
- In the browser, paste the url that displays the console log
- Go to "New" -> "Python 3 (ipykernel)"
- Paste the following code into the notebook cell and execute it
from typing import List
from IPython.display import Javascript, display
from ipywidgets import interactive, Box
display(Javascript('window.myGlobalVar = 0;'))
def _fnc_test():
print ("fnc_test")
display(Javascript('window.myGlobalVar++; console.log("javascript - " + window.myGlobalVar );'))
_fwidget = interactive(_fnc_test)
_layout = Box([_fwidget])
display(_layout)
- Press F12 to display the browser console
Expected behavior
It should display a single line with the message javascript -1
cyberdie commented
This issue is easily reproducible. Could anybody take a look at it?