Skip to content

Commit

Permalink
Fix rendering of backticks in ReactiveHTML (#5512)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr authored Sep 14, 2023
1 parent 1b88afa commit cf1b88f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion panel/models/reactive_html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ export class ReactiveHTMLView extends HTMLBoxView {
}

private _render_html(literal: any, state: any={}): any {
let htm = literal
let htm = literal.replace(/[`]/g, '\\$&');
let callbacks = ''
const methods: string[] = []
for (const elname in this.model.callbacks) {
Expand Down
19 changes: 19 additions & 0 deletions panel/tests/ui/test_reactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ class ReactiveComponent(ReactiveHTML):
'click': 'data.count += 1; reactive.innerText = `${data.count}`;'
}

class ReactiveLiteral(ReactiveHTML):

value = param.String()

_template = """
<div class="reactive">{{value}}</div>
"""


def test_reactive_html_click_js_event(page, port):
component = ReactiveComponent()
Expand Down Expand Up @@ -104,3 +112,14 @@ def test_reactive_html_set_background_no_rerender(page, port):
component.styles = dict(background='green')
time.sleep(0.1)
expect(page.locator(".reactive")).to_have_text('1')

def test_reactive_literal_backtick(page, port):
component = ReactiveLiteral(value="Backtick: `")

serve(component, port=port, threaded=True, show=False)

time.sleep(0.2)

page.goto(f"http://localhost:{port}")

expect(page.locator(".reactive")).to_have_text('Backtick: `')

0 comments on commit cf1b88f

Please sign in to comment.