mirror of
https://github.com/zulip/zulip.git
synced 2025-11-19 14:08:23 +00:00
zjquery: Tell user why using tags as selector is invalid.
Like using $('input') is too broad a selector and shouldn't
be used in the codebase. With this error messages, contributors
can easily understand that now.
This commit is contained in:
committed by
Steve Howell
parent
269457c58b
commit
2b8921bf67
@@ -29,8 +29,15 @@ function verify_selector_for_zulip(selector) {
|
|||||||
(selector.includes("[") && selector.indexOf("]") >= selector.indexOf("["));
|
(selector.includes("[") && selector.indexOf("]") >= selector.indexOf("["));
|
||||||
|
|
||||||
if (!is_valid) {
|
if (!is_valid) {
|
||||||
|
// Check if selector has only english alphabets and space.
|
||||||
|
// Then, the user is probably trying to use a tag as a selector
|
||||||
|
// like $('div a').
|
||||||
|
if (/^[ A-Za-z]+$/.test(selector)) {
|
||||||
|
throw new Error("Selector too broad! Use id, class or attributes of target instead.");
|
||||||
|
} else {
|
||||||
throw new Error("Invalid selector: " + selector + " Use $.create() maybe?");
|
throw new Error("Invalid selector: " + selector + " Use $.create() maybe?");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function make_event_store(selector) {
|
function make_event_store(selector) {
|
||||||
|
|||||||
Reference in New Issue
Block a user