Skip to content
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
2 changes: 2 additions & 0 deletions panel/io/pyodide.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ def pysync(event):

try:
pydoc.unhold()
pydoc.on_event('document_ready', functools.partial(state._schedule_on_load, pydoc))
pydoc.callbacks.trigger_event(DocumentReady())
except Exception as e:
print(f'Error raised while processing Document events: {e}') # noqa: T201
Expand Down Expand Up @@ -389,6 +390,7 @@ def pysync(event):

doc.on_change(pysync)
doc.unhold()
doc.on_event('document_ready', functools.partial(state._schedule_on_load, doc))
doc.callbacks.trigger_event(DocumentReady())

async def _link_model(ref: str, doc: Document) -> None:
Expand Down
22 changes: 22 additions & 0 deletions panel/tests/ui/io/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,19 @@ def on_click(e):
pn.Row('Output').servable();
"""

onload_app = """
import panel as pn

row = pn.Row('Foo')

def onload():
row[:] = ['Bar']

pn.state.onload(onload)

row.servable()
"""


@pytest.fixture(scope="module")
def http_serve():
Expand Down Expand Up @@ -264,3 +277,12 @@ def test_pyodide_test_convert_png_app(http_serve, page, runtime):
expect(page.locator('img')).to_have_count(1)

assert [msg for msg in msgs if msg.type == 'error' and 'favicon' not in msg.location['url']] == []


@pytest.mark.parametrize('runtime', ['pyodide', 'pyodide-worker'])
def test_pyodide_test_convert_onload_app(http_serve, page, runtime):
msgs = wait_for_app(http_serve, onload_app, page, runtime)

expect(page.locator('.markdown')).to_have_text('Bar')

assert [msg for msg in msgs if msg.type == 'error' and 'favicon' not in msg.location['url']] == []
Loading