Commit 0a288a2e authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Set current event target in fire_event_obj.

parent 6dc67c42
......@@ -812,7 +812,7 @@ static HTMLEventObj *create_event(void)
return ret;
}
static HRESULT set_event_info(HTMLEventObj *event, EventTarget *target, eventid_t eid, HTMLDocumentNode *doc, nsIDOMEvent *nsevent)
static HRESULT set_event_info(HTMLEventObj *event, eventid_t eid, HTMLDocumentNode *doc, nsIDOMEvent *nsevent)
{
event->type = event_info+eid;
event->nsevent = nsevent;
......@@ -832,9 +832,6 @@ static HRESULT set_event_info(HTMLEventObj *event, EventTarget *target, eventid_
}
}
event->target = target;
if(target)
IDispatchEx_AddRef(&target->dispex.IDispatchEx_iface);
return S_OK;
}
......@@ -1109,6 +1106,11 @@ static void fire_event_obj(EventTarget *event_target, eventid_t eid, HTMLEventOb
if(target_vtbl && target_vtbl->set_current_event)
prev_event = target_vtbl->set_current_event(&event_target->dispex, event_obj ? &event_obj->IHTMLEventObj_iface : NULL);
if(event_obj) {
event_obj->target = event_target;
IDispatchEx_AddRef(&event_target->dispex.IDispatchEx_iface);
}
for(i = 0; i < chain_cnt; i++) {
call_event_handlers(event_obj, target_chain[i], eid);
if(!(event_info[eid].flags & EVENT_BUBBLES) || (event_obj && event_obj->cancel_bubble))
......@@ -1156,7 +1158,7 @@ void fire_event(HTMLDocumentNode *doc, eventid_t eid, BOOL set_event, EventTarge
if(!event_obj)
return;
hres = set_event_info(event_obj, target, eid, doc, nsevent);
hres = set_event_info(event_obj, eid, doc, nsevent);
if(FAILED(hres)) {
IHTMLEventObj_Release(&event_obj->IHTMLEventObj_iface);
return;
......@@ -1206,7 +1208,7 @@ HRESULT dispatch_event(HTMLDOMNode *node, const WCHAR *event_name, VARIANT *even
}
if(event_obj) {
hres = set_event_info(event_obj, &node->event_target, eid, node->doc, NULL);
hres = set_event_info(event_obj, eid, node->doc, NULL);
if(SUCCEEDED(hres))
fire_event_obj(&node->event_target, eid, event_obj);
......
......@@ -176,6 +176,21 @@ function test_body_events() {
ok(onclick_called, "onclick handler not invoked");
}
function test_event_target() {
var div = document.createElement("div");
document.body.appendChild(div);
var last_event_arg;
div.attachEvent("onclick", function(event_arg) {
ok(event_arg.srcElement === div, "srcElement != div");
last_event_arg = event_arg;
});
div.click();
with(todo_wine)
ok(last_event_arg.srcElement === null, "srcElement != null");
}
window.onload = function() {
try {
ok(inlscr_complete_called, "onreadystatechange not fired");
......@@ -198,6 +213,7 @@ window.onload = function() {
test_insert_script();
test_string_event_handler();
test_body_events();
test_event_target();
}catch(e) {
ok(false, "Got an exception: " + e.message);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment