Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #27367
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: XMLHttpRequest and Google Chrome |
| Date | 2015-04-13 22:28 +0200 |
| Organization | PointedEars Software (PES) |
| Message-ID | <178624004.XKlV7BFGNV@PointedEars.de> (permalink) |
| References | (3 earlier) <130420151317399772%timstreater@greenbee.net> <mggd3o$n6r$1@dont-email.me> <87h9skyte6.fsf@bsb.me.uk> <mggm7e$qbf$1@dont-email.me> <mggock$rt7$1@solani.org> |
Christoph M. Becker wrote:
> The onload property of the window element
s/element/object/
> is supposed to hold the reference to a Function object (or null). This
> function object is automatically called (with a single argument, namely
> the respective Event object[1]) after the documented has been loaded.
s/documented/document/
Also, one must carefully consider what it means that “a document has been
loaded”. Historically, there has been an inconsistency among layout engines
with regard to loading the image resources referred by a document, for
example.
> […]
> [1] This argument isn't supplied in old versions of MSHTML.
… and in MSHTML 9+ when in a backwards-compatible browser mode.
In general, one should not write such code, but use a wrapper that only
falls back to “.on…” in case .addEventListener() is not available, in a way
that works like .addEventListener().
The disadvantage of the .on… properties is that, if used directly, the code
not only overwrites any event listener previously defined in *this* way, but
today’s test in WebKit as of "Mozilla/5.0 (X11; Linux x86_64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36"
shows that this can place the new event listener *after* all other listeners
for the same event type.
This can be tested by example of the “click” event of the “body” element
using
document.body.onclick = function () { console.log(1337); };
document.body.addEventListener("click",
function () { console.log(42); },
false);
document.body.onclick = function () { console.log(23); };
and then clicking somewhere within the document body. In the aforementioned
environment, I get
42
23
which shows that the event listener is replaced *and* moved.
After a subsequent
document.body.addEventListener("click",
function () { console.log(1701); },
false);
call, I get
42
23
1701
when clicking, which shows that .addEventListener() preserves the listener
order: the new listener comes not only after all listeners added with
.addEventListener(), but all listeners for the same event no matter how they
were added (including .onclick assignments).
If I repeat the second .onclick assignment, I get
42
1701
23
when clicking. So I must assume that this is the implemented behavior and
cannot be attributed to an arbitrary order of calling the listeners.
[I have not checked the HTML5 Specification for this yet. That
.addEventListener() would preserve listener order was specified in DOM Level
3 Events, and implemented so before HTML5, but that specification did not
say anything about how .addEventListener() was supposed to work in
combination with event-handler properties on element objects.]
That said, such considerations may not be relevant with certain other
objects and event types. It is then merely a matter of consistency in the
application design.
--
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
XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-12 19:36 +0100
Re: XMLHttpRequest and Google Chrome JJ <jj4public@vfemail.net> - 2015-04-13 12:33 +0700
Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-13 07:41 +0100
Re: XMLHttpRequest and Google Chrome Martin Honnen <mahotrash@yahoo.de> - 2015-04-13 11:30 +0200
Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-13 11:50 +0100
Re: XMLHttpRequest and Google Chrome Tim Streater <timstreater@greenbee.net> - 2015-04-13 13:17 +0100
Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-13 13:34 +0100
Re: XMLHttpRequest and Google Chrome Tim Streater <timstreater@greenbee.net> - 2015-04-13 14:26 +0100
Re: XMLHttpRequest and Google Chrome Martin Honnen <mahotrash@yahoo.de> - 2015-04-13 16:15 +0200
Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-13 16:03 +0100
Re: XMLHttpRequest and Google Chrome Martin Honnen <mahotrash@yahoo.de> - 2015-04-13 19:26 +0200
Re: XMLHttpRequest and Google Chrome "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-04-13 20:23 +0200
Re: XMLHttpRequest and Google Chrome Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-04-13 15:50 +0100
Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-13 16:10 +0100
Re: XMLHttpRequest and Google Chrome "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-04-13 17:46 +0200
Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-13 17:28 +0100
Re: XMLHttpRequest and Google Chrome "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-04-13 19:14 +0200
Re: XMLHttpRequest and Google Chrome Tim Streater <timstreater@greenbee.net> - 2015-04-13 18:29 +0100
Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-13 18:59 +0100
Re: XMLHttpRequest and Google Chrome "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-04-13 20:29 +0200
Re: XMLHttpRequest and Google Chrome Tim Streater <timstreater@greenbee.net> - 2015-04-13 19:34 +0100
Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-13 20:11 +0100
Re: XMLHttpRequest and Google Chrome "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-04-13 20:44 +0200
Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-13 20:21 +0100
Re: XMLHttpRequest and Google Chrome Denis McMahon <denismfmcmahon@gmail.com> - 2015-04-14 12:43 +0000
Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-14 14:50 +0100
Re: XMLHttpRequest and Google Chrome Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-04-14 22:51 +0200
Re: XMLHttpRequest and Google Chrome Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-04-13 22:28 +0200
Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-13 19:23 +0100
Re: XMLHttpRequest and Google Chrome Tim Streater <timstreater@greenbee.net> - 2015-04-13 19:38 +0100
Re: XMLHttpRequest and Google Chrome "Leonardo Azpurua" <leonardo@exmvps.org> - 2015-04-13 17:36 -0430
Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-14 11:35 +0100
Re: XMLHttpRequest and Google Chrome Denis McMahon <denismfmcmahon@gmail.com> - 2015-04-14 11:37 +0000
csiph-web