Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
web: Convert .data("code-language") to .attr.
Anders Kaseorgabee323c772c
diff --git a/web/src/playground_links_popover.ts b/web/src/playground_links_popover.tsindex 7407c2bd3ed..dd52f95aaa6 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.tsindex 898651fedb4..b2c250bca46 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.jsindex ee080f10bc6..68d55c3982e 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"],