mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 23:13:25 +00:00
setup: Fix wildly unsafe cast in $.fn.expectOne.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
affdffdda5
commit
55e4be0939
@@ -72,7 +72,7 @@ function display_avatar_delete_started(): void {
|
|||||||
|
|
||||||
export function build_user_avatar_widget(upload_function: UploadFunction): void {
|
export function build_user_avatar_widget(upload_function: UploadFunction): void {
|
||||||
const get_file_input = function (): JQuery<HTMLInputElement> {
|
const get_file_input = function (): JQuery<HTMLInputElement> {
|
||||||
return $("#user-avatar-upload-widget .image_file_input").expectOne();
|
return $<HTMLInputElement>("#user-avatar-upload-widget input.image_file_input").expectOne();
|
||||||
};
|
};
|
||||||
|
|
||||||
if (page_params.avatar_source === "G") {
|
if (page_params.avatar_source === "G") {
|
||||||
|
|||||||
2
web/src/global.d.ts
vendored
2
web/src/global.d.ts
vendored
@@ -23,7 +23,7 @@ declare namespace JQueryValidation {
|
|||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
|
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
|
||||||
interface JQuery {
|
interface JQuery {
|
||||||
expectOne<T extends HTMLElement>(): JQuery<T>;
|
expectOne(): this;
|
||||||
get_offset_to_window(): DOMRect;
|
get_offset_to_window(): DOMRect;
|
||||||
tab(action?: string): this; // From web/third/bootstrap
|
tab(action?: string): this; // From web/third/bootstrap
|
||||||
modal(action?: string): this; // From web/third/bootstrap
|
modal(action?: string): this; // From web/third/bootstrap
|
||||||
|
|||||||
@@ -26,10 +26,10 @@ $(() => {
|
|||||||
return this[0].getBoundingClientRect();
|
return this[0].getBoundingClientRect();
|
||||||
};
|
};
|
||||||
|
|
||||||
$.fn.expectOne = function <T>() {
|
$.fn.expectOne = function () {
|
||||||
if (blueslip && this.length !== 1) {
|
if (blueslip && this.length !== 1) {
|
||||||
blueslip.error("Expected one element in jQuery set", {length: this.length});
|
blueslip.error("Expected one element in jQuery set", {length: this.length});
|
||||||
}
|
}
|
||||||
return this as JQuery<T>;
|
return this;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user