mirror of https://github.com/zulip/zulip.git
Add a `.expectOne` method to jQuery objects.
It asserts that the result set is exactly one element. (imported from commit c78ff131deb4a13c65c2a68e4b8e09279ece3ea0)
This commit is contained in:
parent
2f8bd32ef8
commit
9428f40422
|
@ -315,6 +315,15 @@ exports.enforce_arity = function util_enforce_arity(func) {
|
|||
};
|
||||
};
|
||||
|
||||
if (typeof $ !== 'undefined') {
|
||||
$.fn.expectOne = function () {
|
||||
if (blueslip && this.length !== 1) {
|
||||
blueslip.error("Expected one element in jQuery set, " + this.length + " found");
|
||||
}
|
||||
return this;
|
||||
};
|
||||
}
|
||||
|
||||
return exports;
|
||||
}());
|
||||
if (typeof module !== 'undefined') {
|
||||
|
|
Loading…
Reference in New Issue