Skip to content

Commit

Permalink
Redraw if stylesheets is empty (#6365)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro committed Feb 20, 2024
1 parent d4a216e commit b9b7613
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
16 changes: 8 additions & 8 deletions panel/models/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ export class PanelMarkupView extends WidgetView {
for (const sts of this._applied_stylesheets) {
const style_el = (sts as any).el
if (style_el instanceof HTMLLinkElement) {
this._initialized_stylesheets[style_el.href] = false
style_el.addEventListener("load", () => {
this._initialized_stylesheets[style_el.href] = true
if (
Object.values(this._initialized_stylesheets).every(Boolean)
)
this.style_redraw()
})
this._initialized_stylesheets[style_el.href] = false
style_el.addEventListener('load', () => {
this._initialized_stylesheets[style_el.href] = true
if (Object.values(this._initialized_stylesheets).every(Boolean))
this.style_redraw()
})
}
}
if (Object.keys(this._initialized_stylesheets).length === 0)
this.style_redraw()
}

style_redraw(): void {
Expand Down
13 changes: 13 additions & 0 deletions panel/tests/ui/pane/test_markup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from html import escape

import pytest

pytest.importorskip("playwright")

from playwright.sync_api import expect

from panel.models import HTML
from panel.pane import Markdown
from panel.tests.util import serve_component, wait_until

Expand Down Expand Up @@ -85,3 +88,13 @@ def test_markdown_pane_visible_toggle(page):
md.visible = True

wait_until(lambda: page.locator(".markdown").locator("div").is_visible(), page)

def test_html_model_no_stylesheet(page):
# regression test for https://github.com/holoviz/holoviews/issues/5963
text = "<h1>Header</h1>"
html = HTML(text=escape(text), width=200, height=200)
serve_component(page, html)

header_element = page.locator('h1:has-text("Header")')
assert header_element.is_visible()
assert header_element.text_content() == "Header"

0 comments on commit b9b7613

Please sign in to comment.