The above code is just to skip processing for text nodes (nodeType == 3) and comments (nodeType == 8), which do not have events.
Windows are the only elements which lack a nodeType, but for which events (resize, focus) are possible. Here's a better test case: http://s3.amazonaws.com/iframeWindowTest/index.html Jed Schmidt On Feb 26, 4:51 pm, Diego Perini <diego.per...@gmail.com> wrote: > Jed, > I would like to add that a few lines above the ones you pointed out we > also have: > > if ( elem.nodeType == 3 || elem.nodeType == 8 ) > return; > > Can "elem" really be a window/frame reference ? > > Shouldn't this give an error since windows/frames do not have a > "nodeType" property or am I missing the obvious ? > > Diego > > On 27 Feb, 00:39, Jed Schmidt <t...@nslator.jp> wrote: > > > Hello all, > > > I'm having trouble binding events to the window of a child iframe: > > > $("<iframe/>") > > .bind( "load", function() { > > $( this.contentWindow ).bind( function() { > > console.log( this == window ) // true, should be false > > }) > > .appendTo( document.body ) > > > Basically, events bound to the window of a child frame end up being > > bound to the window in which jQuery is running. I think this might be > > because of the following section in jQuery.event.add: > > > // For whatever reason, IE has trouble passing the window object > > // around, causing it to be cloned in the process > > if ( elem.setInterval && elem != window ) > > elem = window; > > > This condition mistakenly triggers for child windows, because they > > have the setInterval method but are not the main window. > > > I think this can be fixed by changing line 2587 to: > > > if ( elem.setInterval && ( elem != window || !elem.frameElement ) ) > > elem = window; > > > Jed Schmidt > > > PS: Also, after doing some iframe-related work, I have a few ideas > > about making jQuery more intuitive: > > > (1) $.fn.html should have a case for iframes that calls open/write/ > > close for the frame's document, enabling $("<iframe/>").html > > ("<html><body>Hello world</body></html>") > > > (2) $.fn.parent and $.fn.children should work for windows, returning > > their child/parent windows where possible. > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~----------~----~----~----~------~----~------~--~---