[whatwg] Progress Events "done" event

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.
Sincerely,
Chris

-----Original Message-----
From: whatwg-bounces@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.

Received on Monday, 27 August 2007 00:26:55 UTC