Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Re: Event target in browsers Date: Fri, 30 May 2014 14:31:15 +0200 Organization: PointedEars Software (PES) Lines: 45 Message-ID: <2293814.oF4AcP8BYo@PointedEars.de> References: <69413$5387765f$6def49ce$18425@nntpswitch.blueworldhosting.com> <5294499.JCWY7Ix9cy@PointedEars.de> <53886ae7$0$6657$9b4e6d93@newsspool3.arcor-online.net> Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: solani.org 1401453077 21932 eJwFwQERADEIAzBLG9DukAMP9S/hEzgvvxcEA4I6a3UUgtmJ522sbI1Hj9g+VZuN4blYaX8ydhJM (30 May 2014 12:31:17 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Fri, 30 May 2014 12:31:17 +0000 (UTC) User-Agent: KNode/4.12.4 X-User-ID: eJwFwQERADEIAzBLK6MF5HDs8S/hE15BEy7KudxURTO9R6e9YJnruN/jG31JyIKDxgVYUTs8TEaPRdjuDypWFFw= Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg== X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. 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 for details.) -- PointedEars FAQ: | SVN: Twitter: @PointedEars2 | ES Matrix: Please do not Cc: me. / Bitte keine Kopien per E-Mail.