[JSMentors] Re: Detect DOM Node Removal?

2011-03-17 Thread Matt Kruse
On Mar 17, 5:17 pm, Diego Perini wrote: > This (3) seems to me the best solution but use > "compareDocumentPosition()" method instead. I just learned of this method today. Very handy! > maybe you could use method 2 and "matchesSelector()" to avoid using an > expensive > universal "*" selector i

[JSMentors] Re: Array and for/in syntax

2011-03-17 Thread RobG
On Mar 18, 8:22 am, Diego Perini wrote: > On Thu, Mar 17, 2011 at 3:01 AM, RobG wrote: > > > On Mar 17, 10:47 am, RobG wrote: > >> On Mar 17, 10:40 am, RobG wrote: > >> [...] > > >> > Try this in various browsers: > > >> > (function() { > >> [...] > >> > })(); > > >> Here's one I forgot to a

Re: [JSMentors] Re: Array and for/in syntax

2011-03-17 Thread Diego Perini
On Thu, Mar 17, 2011 at 3:01 AM, RobG wrote: > > > On Mar 17, 10:47 am, RobG wrote: >> On Mar 17, 10:40 am, RobG wrote: >> [...] >> >> >  Try this in various browsers: >> >> > (function() { >> [...] >> > })(); >> >> Here's one I forgot to add: >> >>   // How about an array object >>   var arr =

Re: [JSMentors] Detect DOM Node Removal?

2011-03-17 Thread Diego Perini
On Thu, Mar 17, 2011 at 5:32 PM, Matt Kruse wrote: > I have a reference to a DOM node. I want to know when it is removed > from the document, even if it was caused by a PARENT node being > removed! > (Firefox 3.5+, Chrome, Safari, Opera, don't care about IE) > > I'll cover the obvious: > > 1) DOMN

[JSMentors] Re: Detect DOM Node Removal?

2011-03-17 Thread Scott Sauyet
On Mar 17, 12:32 pm, Matt Kruse wrote: > I have a reference to a DOM node. I want to know when it is removed > from the document, even if it was caused by a PARENT node being > removed! If you have a node you want to track, can't you just keep a reference to each element in its ancestry and note

[JSMentors] Detect DOM Node Removal?

2011-03-17 Thread Matt Kruse
I have a reference to a DOM node. I want to know when it is removed from the document, even if it was caused by a PARENT node being removed! (Firefox 3.5+, Chrome, Safari, Opera, don't care about IE) I'll cover the obvious: 1) DOMNodeRemovedFromDocument: Doesn't bubble, and only fires on the actu

[JSMentors] Re: adding a sound clip

2011-03-17 Thread cancel bubble
This is probably worth a read: How to play a sound in a web browser (it ain't easy) http://mir.aculo.us/2011/03/16/how-to-play-a-sound-in-a-web-browser-it-aint-easy/ -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/jsmentors@jsmentors.com/

Re: [JSMentors] Edge cases with function declarations

2011-03-17 Thread Poetro
2011/3/17 Peter van der Zee : > function f(){}  // var f is hoisted and will contain the function > var f = function(){}; // var f is hoisted but the function value is NOT > var f = function g(){}; // var f is hoisted but the function value is NOT. > var g should not be hoisted, or even exist, beca

Re: [JSMentors] Edge cases with function declarations

2011-03-17 Thread shaun etherton
On Thu, Mar 17, 2011 at 6:23 PM, Peter van der Zee wrote: > > When you want to create functions depending on some factor (so inside an > if), as far as the specification goes, you can only use function expressions > (var f = function ...). > > So, recap: > > function f(){} // var f is hoisted and

[JSMentors] Re: Edge cases with function declarations

2011-03-17 Thread RobG
On Mar 16, 9:37 pm, Peter van der Zee wrote: > On Mon, Mar 14, 2011 at 12:06 PM, Bruno Jouhier wrote: > > Is this behavior precisely defined by the ECMAScript standard, or is > > it left open to interpretation? > > Enter Yuri or Dmitry ;) There are a number of threads on clj, e.g. "Named func

Re: [JSMentors] Edge cases with function declarations

2011-03-17 Thread Peter van der Zee
On Wed, Mar 16, 2011 at 4:05 PM, shaun wrote: > > > I think i read in the Google Javascript style guide that for situations > like the one above, functions should be declared like: > > var f = function... > > I guess this is so var hoisting does the "right thing" for you? > No. I actually didn't