Event.observe(window, 'load'.. issue not fixed!

已查看 769 次
跳至第一个未读帖子

Dziamid

未读,
2010年4月15日 09:03:492010/4/15
收件人 Prototype: Core
Event.observe(window, 'load', function () {
alert('1');
});
Event.observe(window, 'load', function () {
alert('2');
});
Firefox, opera alerts "1" then "2", IE alerts "2" THEN "1"!! Order is
reversed and developeres are puzzled! Why isn't this issue still
fixed?!

T.J. Crowder

未读,
2010年4月15日 11:51:222010/4/15
收件人 Prototype: Core
Hi,

> Why isn't this issue still
> fixed?!

You say "still." Is there an _open_ bug report for it in
Lighthouse[1]? Because if there isn't, it's not going to be "fixed."

In any case, I don't think it would be a fix, it would be an
enhancement. As far as I know, Prototype does not make any guarantee
as to the order in which multiple event handlers on an element will be
called (because there is no guarantee provided by the underlying
APIs). To do so, Prototype would have to replace the browser's list of
event observers with its own, which would be overkill (IMHO).

[1] http://prototype.lighthouseapp.com/projects/8886-prototype/overview
--
T.J. Crowder
Independent Software Consultant
tj / crowder software / com
www.crowdersoftware.com

Johan Arensman

未读,
2010年4月15日 12:47:092010/4/15
收件人 prototy...@googlegroups.com
Hello... Dziamid,

Please the tone of your message is far but polite. The developers of the prototype project will do everything they can to address issues as they can. It's not like they don't want to fix certain issues on purpose.

They are users also so if there are nasty bugs in prototype.js I'm sure they will do every they can to get them out so they also get a better library.

A simple 'hello' and 'kind regards' would have been a lot nicer for everyone to see in their mailbox. Yes, everyone receives this message, not only the authors of prototype.js.

Greetings,
 Johan Arensman

--
You received this message because you are subscribed to the Google Groups "Prototype: Core" group.
To post to this group, send email to prototy...@googlegroups.com
To unsubscribe from this group, send email to prototype-cor...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en

To unsubscribe, reply using "remove me" as the subject.

Mislav Marohnić

未读,
2010年4月15日 14:23:462010/4/15
收件人 prototy...@googlegroups.com
I think that "dom:loaded" handlers should execute in order, since it's a custom event. Try those instead of "load".

document.on("dom:loaded", function(){ ... })

Tom Gregory

未读,
2010年4月15日 15:40:022010/4/15
收件人 prototy...@googlegroups.com
I'm going to agree with others, and say a) this is not a bug, and b) isn't worth making the change. The observer pattern (on which the event architecture is based), by design, does not guarantee order; nor should it, as it would imply the observers are not orthogonal.

If you have order dependencies, can I suggest reworking your code? One workaround Javascript provides is the ability to pass, assign, and wrap functions. e.x.:

var A = function() {alert('A');}
var A2 = A;
A = function() {alert('New A'); A2();}
A(); // Alerts "New A", then alerts "A"

See also, Function#wrap in Prototype. [ http://api.prototypejs.org/language/function/prototype/wrap/ ]

If you choose that route, further questions on that feature should be sent to the users' group.


TAG

Демид Заянковский

未读,
2010年4月19日 06:54:202010/4/19
收件人 prototy...@googlegroups.com
No, unfortunately the order is till not preserved for DOM:LOADED event. Thank you for your suggestion.

2010/4/15 Mislav Marohnić <mislav....@gmail.com>
I think that "dom:loaded" handlers should execute in order, since it's a custom event. Try those instead of "load".

document.on("dom:loaded", function(){ ... })

--
You received this message because you are subscribed to the Google Groups "Prototype: Core" group.
To post to this group, send email to prototy...@googlegroups.com
To unsubscribe from this group, send email to prototype-cor...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en

Демид Заянковский

未读,
2010年4月19日 07:01:332010/4/19
收件人 prototy...@googlegroups.com
> In any case, I don't think it would be a fix
Well, that's a shame. I know that browsers do not gurantee the order in which the event handlers execute, but it is such a convinient and straightforward approach to do so, isn't it. That is why Firefox, Opera and all the best browsers embraced it. IE is the outcast the ruins the picture. If you look at the jQuery library, it does a "fix" for IE! Anyway, thank you for your attention.

2010/4/15 T.J. Crowder <t...@crowdersoftware.com>
--
You received this message because you are subscribed to the Google Groups "Prototype: Core" group.
To post to this group, send email to prototy...@googlegroups.com
To unsubscribe from this group, send email to prototype-cor...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en

To unsubscribe, reply using "remove me" as the subject.

Демид Заянковский

未读,
2010年4月19日 07:05:412010/4/19
收件人 prototy...@googlegroups.com
Sorry for being impoly, never thought I would get somebody's attention to my letter. It's just very frustraiting "bug" for me and I was very dissapointed to not see the change in the new version of Prototype. Thank you for your attention.

2010/4/15 Johan Arensman <joha...@gmail.com>

Демид Заянковский

未读,
2010年4月19日 07:14:552010/4/19
收件人 prototy...@googlegroups.com
Well, to be honest, I've been focusing on Firefox and Opera mainly when developing software and never even thought that order is not guaranteed, before the task to support IE arrived! So there is plenty of code to refactor, which is very frustrating. I know that relying on event order isn't a best practice, but such a convinent one. jQuery guys would understand me, because their events are always executing in defined order.

2010/4/15 Tom Gregory <to...@byu.net>
回复全部
回复作者
转发
0 个新帖子