Diego,

Thanks for taking a look. I've distilled the test case down to make it
simpler:

http://s3.amazonaws.com/iframeWindowTest/before.html
http://s3.amazonaws.com/iframeWindowTest/after.html

And submitted a bug here:

http://dev.jquery.com/ticket/4268

Jed Schmidt

On Feb 27, 7:26 am, Diego Perini <diego.per...@gmail.com> wrote:
> Jed,
> now your test is accessible, I can load it.
>
> One problem I noticed:
>
> frameWindow.onresize = function( e ) {
>    $("<div/>")
>       .text( "DOM " + e.type + " event on the " + this.name + " at " +
> +new Date )
>       .prependTo( frameWindow.document.body );
>    }
>
> when using DOM0 events IE will not pass the "e" event argument to the
> handler.
>
> So the above will error on IE when trying to access the "type"
> property of an undefined object ("e").
>
> I don't recommend using the simple "e || (e = window.event)" since you
> are handling iframes, use the "this" keyword instead, find the
> ownerDocument, then find the "parentWindow" or
> "defaultView" (depending on browser) and get the event from that
> object.
>
> After correcting the above in your test I still get errors in
> jquery-1.3.2.js because seemingly at some point "ret[i]" value is null
> before trying to append it in this piece of code around line 958:
>
>           if ( ret[i].nodeType === 1 )
>                ret.splice.apply( ret, [i + 1, 0].concat
> (jQuery.makeArray(ret[
>           fragment.appendChild( ret[i] );
>
> I should momentarily interrupt the testing to follow up some work but
> will have a look back.
>
> Diego
>
> On 27 Feb, 04:20, Jed Schmidt <t...@nslator.jp> wrote:
>
> > Diego,
>
> > My apologies, I misunderstood you.
>
> > (Also, the test case is working now: resize the window to test it, and
> > see that jQuery is binding one of the resize events incorrectly.)
>
> > Jed Schmidt
>
> > On Feb 26, 6:01 pm, Diego Perini <diego.per...@gmail.com> wrote:
>
> > > Jed,
> > > your test case is not accessible for me. I get "Access denied".
>
> > > Diego
>
> > > On 27 Feb, 02:21, Jed Schmidt <t...@nslator.jp> wrote:
>
> > > > 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to