mirror of https://github.com/zulip/zulip.git
zjquery: Fix event parameter of invoked handlers.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
af3a79ab31
commit
2bbd8265b9
|
@ -846,7 +846,7 @@ run_test("finish", () => {
|
||||||
|
|
||||||
let compose_finished_event_checked = false;
|
let compose_finished_event_checked = false;
|
||||||
$(document).trigger = function (e) {
|
$(document).trigger = function (e) {
|
||||||
assert.equal(e.name, "compose_finished.zulip");
|
assert.equal(e.type, "compose_finished.zulip");
|
||||||
compose_finished_event_checked = true;
|
compose_finished_event_checked = true;
|
||||||
};
|
};
|
||||||
let send_message_called = false;
|
let send_message_called = false;
|
||||||
|
|
|
@ -1,5 +1,14 @@
|
||||||
const noop = function () {};
|
const noop = function () {};
|
||||||
|
|
||||||
|
class Event {
|
||||||
|
constructor(type, props) {
|
||||||
|
this.type = type;
|
||||||
|
Object.assign(this, props);
|
||||||
|
}
|
||||||
|
preventDefault() {}
|
||||||
|
stopPropagation() {}
|
||||||
|
}
|
||||||
|
|
||||||
exports.make_event_store = (selector) => {
|
exports.make_event_store = (selector) => {
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
@ -104,9 +113,11 @@ exports.make_event_store = (selector) => {
|
||||||
child_on.set(event_name, handler);
|
child_on.set(event_name, handler);
|
||||||
},
|
},
|
||||||
|
|
||||||
trigger: function ($element, ev) {
|
trigger: function ($element, ev, data) {
|
||||||
const ev_name = typeof ev === "string" ? ev : ev.name;
|
if (typeof ev === "string") {
|
||||||
const func = on_functions.get(ev_name);
|
ev = new Event(ev, data);
|
||||||
|
}
|
||||||
|
const func = on_functions.get(ev.type);
|
||||||
|
|
||||||
if (!func) {
|
if (!func) {
|
||||||
// It's possible that test code will trigger events
|
// It's possible that test code will trigger events
|
||||||
|
@ -117,7 +128,7 @@ exports.make_event_store = (selector) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
func.call($element, ev.data);
|
func.call($element, ev, data);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -533,12 +544,7 @@ exports.make_zjquery = function (opts) {
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
zjquery.Event = function (name, data) {
|
zjquery.Event = (type, props) => new Event(type, props);
|
||||||
return {
|
|
||||||
name: name,
|
|
||||||
data: data,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
fn.after = function (s) {
|
fn.after = function (s) {
|
||||||
return s;
|
return s;
|
||||||
|
|
Loading…
Reference in New Issue