diff --git a/web/src/playground_links_popover.ts b/web/src/playground_links_popover.ts index 7407c2bd3e..dd52f95aaa 100644 --- a/web/src/playground_links_popover.ts +++ b/web/src/playground_links_popover.ts @@ -98,9 +98,11 @@ function register_click_handlers(): void { const $view_in_playground_button = $(this); const $codehilite_div = $(this).closest(".codehilite"); e.stopPropagation(); - const playground_info = realm_playground.get_playground_info_for_languages( - $codehilite_div.data("code-language"), - ); + const language = $codehilite_div.attr("data-code-language"); + if (language === undefined) { + return; + } + const playground_info = realm_playground.get_playground_info_for_languages(language); if (playground_info === undefined) { return; } diff --git a/web/src/rendered_markdown.ts b/web/src/rendered_markdown.ts index 898651fedb..b2c250bca4 100644 --- a/web/src/rendered_markdown.ts +++ b/web/src/rendered_markdown.ts @@ -278,7 +278,7 @@ export const update_elements = ($content: JQuery): void => { $content.find("div.codehilite").each(function (): void { const $codehilite = $(this); const $pre = $codehilite.find("pre"); - const fenced_code_lang = $codehilite.data("code-language"); + const fenced_code_lang = $codehilite.attr("data-code-language"); let playground_info; if (fenced_code_lang !== undefined) { playground_info = realm_playground.get_playground_info_for_languages(fenced_code_lang); diff --git a/web/tests/rendered_markdown.test.js b/web/tests/rendered_markdown.test.js index ee080f10bc..68d55c3982 100644 --- a/web/tests/rendered_markdown.test.js +++ b/web/tests/rendered_markdown.test.js @@ -547,7 +547,7 @@ function test_code_playground(mock_template, viewing_code) { $content.set_find_results("div.codehilite", $array([$hilite])); $hilite.set_find_results("pre", $pre); - $hilite.data("code-language", "javascript"); + $hilite.attr("data-code-language", "javascript"); const $code_buttons_container = $.create("code_buttons_container", { children: ["copy-code-stub", "view-code-stub"],