Klaus....

Generally, I agree with you with the following caveat. On PPK's site
(http://www.quirksmode.org/js/events_properties.html) he points out a
problem with safari where events get triggered on text nodes instead
of elements. I am hesitant to do

if (e.target.nodeType == 3) { // defeat Safari bug
       e.target = e.target.parentNode;
}

as I don't know whether or not some strange side effects might occur.
I suspect not, but I was being cautious.

A

On 10/20/06, Klaus Hartl <[EMAIL PROTECTED]> wrote:
>
> > fix: function(event) {
> >       if ( event ) {
> >               if( !event.preventDefault ) {
> >                       event.preventDefault = function() {
> >                               this.returnValue = false;
> >                       };
> >               }
> >               if( !event.stopPropagation ) {
> >                       event.stopPropagation = function() {
> >                               this.cancelBubble = true;
> >                       };
> >               }
> >               /*Taken from PPK:
> >               http://www.quirksmode.org/js/events_properties.html
> >               */
> >               var targ;
> >               if (event.target) {
> >                       targ = event.target;
> >               }
> >               else if( event.srcElement ) {
> >                       targ = event.srcElement;
> >               }
> >               if (targ.nodeType == 3) { // defeat Safari bug
> >                       targ = targ.parentNode;
> >               }
> >               event.realTarget = targ;
> >       }
> >       return event;
> > }
> >
> > Now, I haven't actually tested this so there's bound to be a bug
> > somewhere in that code but you get the general idea.
> >
>
>
> Hi Adam,
>
> interesting, I was talking about normalizing the target property quite
> recently as well.
>
> I also think that e.target should be fixed. But I wouldn't use a new
> variable targ for that, instead simply attach target to e in IE:
>
> if (e.srcElement) e.target = e.srcElement;
>
> First I wasn't sure if that would break existing scripts that rely on
> the as-is state. But as most scripts go like this:
>
> var evTarget = e.target || e.srcElement;
>
> that would still work out fine.
>
>
> John or Jörn, shouldn't that be added to the event fix? And maybe the
> two or three other properties that are different from each other?
>
>
> -- Klaus
>
> _______________________________________________
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to