Bug 26578 - event.currentTarget for listener registered on window should point to the window object like in Firefox
Summary: event.currentTarget for listener registered on window should point to the win...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Windows XP
: P2 Normal
Assignee: Sam Weinig
URL:
Keywords: EasyFix
Depends on:
Blocks:
 
Reported: 2009-06-20 18:13 PDT by Michael A. Puls II
Modified: 2009-06-21 13:48 PDT (History)
2 users (show)

See Also:


Attachments
TC that uses the 'input' event (1.33 KB, text/html)
2009-06-20 18:14 PDT, Michael A. Puls II
no flags Details
patch (7.13 KB, patch)
2009-06-21 13:28 PDT, Sam Weinig
eric: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael A. Puls II 2009-06-20 18:13:31 PDT
Safari 4 530.17 with WebKit-r44837

When you register an event listener on the window object, event.currentTarget and 'this' in the callback function should point to the window object. In Firefox, this is true. In Safari, 'this' points to the window, but event.currentTarget points to the document instead. In Opera, they both point to the document.

Firefox's behavior makes the most sense to me.

I asked for clarification at <http://lists.w3.org/Archives/Public/public-html/2009Jun/0566.html>.

This affect the 'input' and 'change' events for example.
Comment 1 Michael A. Puls II 2009-06-20 18:14:07 PDT
Created attachment 31604 [details]
TC that uses the 'input' event
Comment 2 Sam Weinig 2009-06-20 19:02:26 PDT
This is possible now that DOMWindow inherits from EventTarget.  The fix should be in Node.cpp:

2487:        event->setCurrentTarget(targetForWindowEvents->document()); // FIXME: targetForWindowEvents should be the event target.
 
2525:            event->setCurrentTarget(targetForWindowEvents->document()); // FIXME: targetForWindowEvents should be the event target.

Comment 3 Sam Weinig 2009-06-21 13:28:44 PDT
Created attachment 31619 [details]
patch
Comment 4 Eric Seidel (no email) 2009-06-21 13:30:44 PDT
Comment on attachment 31619 [details]
patch

Looks good.
Comment 5 Sam Weinig 2009-06-21 13:48:40 PDT
Fixed in r44913.