Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
zjquery: Tell user why using tags as selector is invalid.
Aman Agrawal2b8921bf67ac
diff --git a/frontend_tests/zjsunit/zjquery.js b/frontend_tests/zjsunit/zjquery.jsindex ed2be134305..84f121f9c56 100644--- a/frontend_tests/zjsunit/zjquery.js+++ b/frontend_tests/zjsunit/zjquery.js@@ -29,7 +29,14 @@ function verify_selector_for_zulip(selector) {(selector.includes("[") && selector.indexOf("]") >= selector.indexOf("["));if (!is_valid) {- throw new Error("Invalid selector: " + selector + " Use $.create() maybe?");+ // 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?");+ }}}