Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
dom_selection: Get and set all CSS on :root.
Karl Stolley4f681abf3cc2
diff --git a/web/src/overlay_util.ts b/web/src/overlay_util.tsindex ee5580c7712..9d323575f47 100644--- a/web/src/overlay_util.ts+++ b/web/src/overlay_util.ts@@ -7,9 +7,9 @@ export function disable_scrolling(): void {// as part of the document flow, we cannot capture `scroll` events on them and prevent propagation// as event bubbling doesn't work naturally.const scrollbar_width = window.innerWidth - document.documentElement.clientWidth;- $("html").css({"overflow-y": "hidden", "--disabled-scrollbar-width": `${scrollbar_width}px`});+ $(":root").css({"overflow-y": "hidden", "--disabled-scrollbar-width": `${scrollbar_width}px`});}export function enable_scrolling(): void {- $("html").css({"overflow-y": "scroll", "--disabled-scrollbar-width": "0px"});+ $(":root").css({"overflow-y": "scroll", "--disabled-scrollbar-width": "0px"});}diff --git a/web/src/realm_logo.ts b/web/src/realm_logo.tsindex 69acd70f96f..c25e4a24340 100644--- a/web/src/realm_logo.ts+++ b/web/src/realm_logo.ts@@ -98,7 +98,7 @@ export function render(): void {$realm_logo.on("load", () => {const logo_width = $realm_logo.width();if (logo_width) {- $("html").css(+ $(":root").css("--realm-logo-current-width",logo_width / user_settings.web_font_size_px + "em",);diff --git a/web/src/recent_view_ui.ts b/web/src/recent_view_ui.tsindex 46622498f6c..ce482e2515e 100644--- a/web/src/recent_view_ui.ts+++ b/web/src/recent_view_ui.ts@@ -1319,7 +1319,7 @@ export function complete_rerender(): void {}if (!page_params.is_node_test) {- max_avatars = Number.parseInt($("html").css("--recent-view-max-avatars"), 10);+ max_avatars = Number.parseInt($(":root").css("--recent-view-max-avatars"), 10);}// Show topics listdiff --git a/web/src/resize.ts b/web/src/resize.tsindex a5371ef8366..2cd8ae96b3b 100644--- a/web/src/resize.ts+++ b/web/src/resize.ts@@ -126,7 +126,7 @@ export function reset_compose_message_max_height(bottom_whitespace_height?: numbexport function resize_bottom_whitespace(): void {const bottom_whitespace_height = get_bottom_whitespace_height();- $("html").css("--max-unmaximized-compose-height", `${bottom_whitespace_height}px`);+ $(":root").css("--max-unmaximized-compose-height", `${bottom_whitespace_height}px`);// The height of the compose box is tied to that of// bottom_whitespace, so update it if necessary.//@@ -174,7 +174,7 @@ export function resize_stream_subscribers_list(): void {total_height_of_classes_above_subscribers_list -subscribers_list_header_height -margin_between_tab_switcher_and_add_subscribers_title;- $("html").css("--stream-subscriber-list-max-height", `${subscribers_list_height}px`);+ $(":root").css("--stream-subscriber-list-max-height", `${subscribers_list_height}px`);}export function resize_stream_filters_container(): void {@@ -192,7 +192,7 @@ export function resize_sidebars(): void {export function update_recent_view(): void {const $recent_view_filter_container = $("#recent_view_filter_buttons");const recent_view_filters_height = $recent_view_filter_container.outerHeight(true) ?? 0;- $("html").css("--recent-topics-filters-height", `${recent_view_filters_height}px`);+ $(":root").css("--recent-topics-filters-height", `${recent_view_filters_height}px`);// Update max avatars to prevent participant avatars from overflowing.// These numbers are just based on speculation.@@ -203,9 +203,9 @@ export function update_recent_view(): void {const num_avatars_narrow_window = 2;const num_avatars_max = 4;if (recent_view_filters_width < media_breakpoints_num.md) {- $("html").css("--recent-view-max-avatars", num_avatars_narrow_window);+ $(":root").css("--recent-view-max-avatars", num_avatars_narrow_window);} else {- $("html").css("--recent-view-max-avatars", num_avatars_max);+ $(":root").css("--recent-view-max-avatars", num_avatars_max);}}diff --git a/web/src/views_util.ts b/web/src/views_util.tsindex 1cd840e1d97..7c36b1bb27e 100644--- a/web/src/views_util.ts+++ b/web/src/views_util.ts@@ -173,7 +173,7 @@ export function is_scroll_position_for_render(): boolean {// new rows to render when the user is scrolling to the bottom of// the view. So, we render new rows when user has scrolled 2 / 3// of (the total scrollable height - the empty space).- const compose_max_height = $("html").css("--max-unmaximized-compose-height");+ const compose_max_height = $(":root").css("--max-unmaximized-compose-height");assert(typeof compose_max_height === "string");const scroll_max = document.body.scrollHeight - Number.parseInt(compose_max_height, 10);return scroll_position + window_height >= (2 / 3) * scroll_max;