Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.straub-nv.de!uucp.gnuu.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="UTF-8" Message-ID: <1602659.Eus3Gmpjyl@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Mon, 11 Feb 2013 01:38:52 +0100 User-Agent: KNode/4.8.5 Content-Transfer-Encoding: 8Bit X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. tag in IE Newsgroups: comp.lang.javascript References: <2542700.24A3Wqytjl@PointedEars.de> <8809769.VO6lmAGIsZ@PointedEars.de> <2710705.sg4g0aCLjx@PointedEars.de> <1522652.FLkxLQDhY3@PointedEars.de> <1573878.qxiknB9TEh@PointedEars.de> MIME-Version: 1.0 Lines: 65 NNTP-Posting-Date: 11 Feb 2013 01:38:54 CET NNTP-Posting-Host: c095950a.newsspool1.arcor-online.net X-Trace: DXC=WnJ;IYkSPBSAX0F2i>YBYU3JEo]8Ub36NnB[_Q X-Complaints-To: usenet-abuse@arcor.de Xref: csiph.com comp.lang.javascript:18447 Eric Bednarz wrote: > Cezary Tomczyk writes: > > [event attributes versus DOM*] > >> Arguments, with which I agree: >> >> http://stackoverflow.com/a/11742769/896702 > > […] > | you are faced with having to reference named functions. This is not > | always ideal (event handlers normally take anonymous functions) > > The what? 'Normally', 'event handlers' are objects that implement the > EventListener interface. No, that would be event *listeners* which are implemented in user code. Event *handlers*, on the other hand, are implemented as built-in code that calls added event listeners (per W3C DOM Level 3 Events explicitly, in order of addition for an event). (AISB) Therefore, you would write el.addEventListener(eventType, eventListener, capturing); to add an event listener for an event type to the represented element or el["on" + eventType.toLowerCase()] = eventListener; to set the primary event listener for that event as non-capturing on the represented element. Event listeners are called by the event handler for an event if they have not been removed later, and an event of a matching type is being propagated to the element. As an (AFAIK undocumented) peculiarity of standards- compliant DOM implementations, the object does not require the handleEvent() method of the EventListener interface to be implemented by the user; it suffices that the Function instance that is the event listener implements is callable, and it is called with the same arguments as handleEvent() would have been. [However, IMHO a DOM event library should augment the Function instance with such a method, for maximum compatibility. jsx.dom.createEventListener() in JSX:events.js does that.] The distinction is necessary because before W3C DOM Level 2 Events it was not possible to have more than one event listener for an event on an element. (Which is why assigning to a then-proprietary event-handler property was often described misleadingly as assigning an “event handler” or an “event”, although the actual implementation did not differ much from the current ones. The wrong terminology is [or was] prevalent in the MSDN Library.) p. > The fantasy nomenclature for function > declarations and expressions aside, function objects created by event > handlers don't have an identifier, so they should be alright (eyeroll). ACK :) -- PointedEars Twitter: @PointedEars2 Please do not Cc: me. / Bitte keine Kopien per E-Mail.