[whatwg] Progress Events "done" event

Křištof Želechovski giecrilj at stegny.2a.pl
Mon Aug 27 00:26:55 PDT 2007

Remember that JavaScript is a programming language after all.  You can use a
loop to get rid of the repetitions.
Start from
var done = ["load", "error", "abort"]...
and apply the closure image.aEL(?, hPB, false) to it.

-----Original Message-----
From: whatwg-bounces at lists.whatwg.org
[mailto:whatwg-bounces at lists.whatwg.org] On Behalf Of Garrett Smith
Sent: Sunday, August 26, 2007 8:25 AM
To: whatwg at whatwg.org
Cc: chaals at opera.com
Subject: [whatwg] Progress Events "done" event

function showImage(imageHref) {

// remove the progress bar when done.
       image.addEventListener("load", hideProgressBar, false);
       image.addEventListener("error", hideProgressBar, false);
       image.addEventListener("abort", hideProgressBar, false);

This is somewhat verbose. Clearly, the author is forced to repeat
himself when all he really wants to do is hide the progress bar after
the call is done.

More information about the whatwg mailing list