Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #24474
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Event target in browsers |
| Date | 2014-05-30 14:31 +0200 |
| Organization | PointedEars Software (PES) |
| Message-ID | <2293814.oF4AcP8BYo@PointedEars.de> (permalink) |
| References | <69413$5387765f$6def49ce$18425@nntpswitch.blueworldhosting.com> <5294499.JCWY7Ix9cy@PointedEars.de> <53886ae7$0$6657$9b4e6d93@newsspool3.arcor-online.net> |
Christoph Michael Becker wrote:
> Thomas 'PointedEars' Lahn wrote:
>> As you are relying on the W3C DOM API already, just use “currentTarget”
>> instead of “target”. (Works in Chromium 34. I need NSAPI plugin
>> support, so I cannot test in Chromium 35 for the time being.)
>
> I can confirm that the currentTarget property works as expected in
> Chrome 35.0.1916.114 m.
>
> Another alternative might be to use "this", as that should be bound to
> the current target by default, if I'm not mistaken.
In Chromium 34 it does, and it did in all previous W3C DOM-enabled browsers
AFAICR, so although I am not aware of a standard saying this, at least it is
a quasi-standard (probably derived from DOM Level 0). You can test it thus:
document.body.addEventListener("click", function (e) {
console.log(e, e.target, e.currentTarget, this);
}, false);
Then primary-click anywhere within the viewport (preferably not on a
navigating widget unless you keep the log then).
It should be noted that logging the value of “e” does not give you the
correct value of the “currentTarget” property in Chromium 34: expanding the
object display shows “currentTarget” and various other properties to be
“null” even though they are not.
OTOH, the object display indicates that Chromium WebCore now also implements
formerly MSHTML-specific properties like “srcElement”. The differences
apparently gradually disappearing, this supports my approach of shallow-
copying event properties to a user-defined object through
jsx.dom.createEventListener() when necessary, instead of others’ approach of
calling user-defined methods from the event listener to sort out the DOM
differences on specific occasion. Because with my approach it is possible
to just stop using the wrapper and continue without modifying the listener
code. (See <http://PointedEars.de/wsvn/JSX/trunk/dom/events.js> for
details.)
--
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not Cc: me. / Bitte keine Kopien per E-Mail.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Event target in browsers Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2014-05-29 20:03 +0200
Re: Event target in browsers Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-05-29 22:35 +0200
Re: Event target in browsers Christoph Michael Becker <cmbecker69@arcor.de> - 2014-05-30 13:26 +0200
Re: Event target in browsers Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-05-30 14:31 +0200
Re: Event target in browsers Christoph Michael Becker <cmbecker69@arcor.de> - 2014-05-30 17:50 +0200
Re: Event target in browsers Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-06-01 22:19 +0200
Re: Event target in browsers Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2014-05-30 20:04 +0200
Re: Event target in browsers Christoph Michael Becker <cmbecker69@arcor.de> - 2014-05-30 20:22 +0200
Re: Event target in browsers Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2014-05-30 20:43 +0200
Re: Event target in browsers Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-05-30 21:47 +0200
Re: Event target in browsers Christoph Michael Becker <cmbecker69@arcor.de> - 2014-05-30 22:29 +0200
Re: Event target in browsers Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-05-31 00:07 +0200
Re: Event target in browsers Christoph Michael Becker <cmbecker69@arcor.de> - 2014-06-02 14:53 +0200
Re: Event target in browsers Christoph Michael Becker <cmbecker69@arcor.de> - 2014-06-02 21:41 +0200
Re: Event target in browsers Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-05-30 21:38 +0200
csiph-web