Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > BOOK: JavaScript Programmer's Reference
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: JavaScript Programmer's Reference
This is the forum to discuss the Wrox book JavaScript Programmer's Reference by Alexei White ISBN: 978-0-470-34472-9
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: JavaScript Programmer's Reference section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 10th, 2010, 07:46 AM
Registered User
Join Date: Aug 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Accidental closures in onmouseleave/enter simulation?

I'm wondering a bit about the code which mimics onmouseleave and onmouseenter events on non-IE browsers, listed on pages 334 and 335 of the book.

For one thing, the events themselves contain quite a bit of spurious processing for the IE-browsers: all that is necessary for these guys is checking whether the code is executed by them, say by looking up e.target or so. For them the crucial final if() will always evaluate to TRUE anyway, so why bother going the extra mile.

Second, and more serious, is that I'm not entirely convinced this code is memory leak-safe. The addEventListener() calls set up explicit references from the object theDiv to itself, and unless I'm mistaken the closures in the (un)hoverElement() calls will keep all variables (target, relTarg, oTarget) alive. On a non-IE browser those might contain references to the object on which mouseover and mouseout were defined, and the result is another circular reference. (See page 125 on accidental closures for comparison.)

If I'm correct about this—and I am really not sure I am, it is a tricky business—then there appears no way in which a non-IE browser can neatly simulate onmouseleave and onmouseenter events, is there?
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 7 Closures and Variables Question Mikeos BOOK: Professional JavaScript for Web Developers 2nd edition ISBN: 9780470227800 2 July 28th, 2010 05:26 PM
Chapter 7 Closures and Variables Question Mikeos BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 0 July 21st, 2010 06:37 PM
XSLT simulation of two column Group By wholden XSLT 2 March 31st, 2008 08:57 AM
Prevent accidental update from a form donevco Access 11 January 18th, 2007 11:30 AM
Chat simulation ahardin59 ASP.NET 2.0 Basics 0 June 26th, 2006 12:22 PM

All times are GMT -4. The time now is 02:44 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.