zjquery: Make FakeElement iterable.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2023-03-01 17:59:32 -08:00 committed by Tim Abbott
parent 6b3edb8b0d
commit 9d514a29d1
1 changed files with 6 additions and 0 deletions

View File

@ -23,6 +23,12 @@ function FakeElement(selector, opts) {
const event_store = make_event_store(selector);
const $self = {
*[Symbol.iterator]() {
// eslint-disable-next-line unicorn/no-for-loop
for (let i = 0; i < $self.length; i += 1) {
yield $self[i];
}
},
addClass(class_name) {
classes.set(class_name, true);
return $self;