#96 enhancement
Viktor Kojouharov

Event fire normal html events.

Reported by Viktor Kojouharov | May 13th, 2008 @ 03:34 PM | in 1.7

Attaches is a patch against today's (13.05.08) git for prototype. It adds the ability of the 'fire' method to emit normal HTML events, such as 'mouseover', 'keydown', 'change', etc. Emitting custom events still works.

The patch was tested in Firefox 2.0 (linux), Firefox 3.0 (linux), IE6, Safari 3 (win) and Opera 9.26 (win) without any errors. Don't have a Mac to test Safari 2 (don't even know how relevant that browser is anymore either).

Comments and changes to this ticket

  • John-David Dalton

    John-David Dalton May 13th, 2008 @ 03:51 PM

    Can you compare your patch to Juriy's version and take the good parts and combine them?

    I think he has ya beat on code size footprint.

    It's definitely worth a look :)


    -- JDD

  • John-David Dalton

    John-David Dalton May 13th, 2008 @ 03:53 PM

    • Milestone set to 1.7
    • Assigned user set to “Juriy Zaytsev”
    • Title changed from “[Patch] Event.fire emits normal HTML events” to “Event fire normal html events.”
  • Viktor Kojouharov

    Viktor Kojouharov May 13th, 2008 @ 04:17 PM


    Someone else will have to do that. I'm biased, so I probably won't make the correct decisions regarding what parts from what to take.


    He definitely beats me in terms of code-size.

    Certain things that I personally didn't like:

    On the bad side, 'simulate' lacks key event simulation.

    Adding another method which is essentially 'fire', but with regular HTML events is a bit redundant.

    I don't know whether the regex match will present any slowdown, as opposed to a hash fetch.

    The default options, in terms of bubble and cancel will be wrong on some of the events. That's the reason I went with a separate bubble|cancel default option for the HTML events.


    to Juriy, please don't take the above heredoc the wrong way. I'm sure you'll have planty of objections against my patch as well :)

  • Viktor Kojouharov

    Viktor Kojouharov May 13th, 2008 @ 04:18 PM

    That lone '<' in the previous comment was the start of the heredoc 'MY_BIASED_OPINION'.

  • Tobie Langel

    Tobie Langel May 13th, 2008 @ 05:18 PM

    • State changed from “new” to “enhancement”
  • Juriy Zaytsev

    Juriy Zaytsev May 13th, 2008 @ 07:36 PM

    • State changed from “enhancement” to “new”


    the snippet from protolicious repository was not actually intended to be used as a patch : ) , but rather a standalone replacement of Event.simulate from unittest.js (which currently supports FF only)

    The reason for not including KeyEvents is a lack of research on this matter. YUI, for example, does not support them and I have a feeling that it's due to a large amount of quirks in the way browsers handle them.

    Having said that, I would really like to hear why such support would be useful. I can't really think of any use cases other than UI testing - exactly the reason why I left it in unittest.js (http://thinkweb2.com/projects/pr...)

  • Viktor Kojouharov

    Viktor Kojouharov May 13th, 2008 @ 11:16 PM


    As far as usefulness is concerned, there are a few things to point out. First, it makes the fire implementation more complete (as long as it's working, and so far it is). Second, it's about as useful as any other event. You want to notify some potential listeners that you did something. Sometimes you want to cheat, and notify them, even if you didn't do exactly that 'something'. And sometimes, we want to fire them, just because the browser pissed us off, and didn't fire them on its own ('change') :). But I'm mostly aiming for complete, it would just suck to be able to fire a mousedown, but not a keydown.

  • Juriy Zaytsev

    Juriy Zaytsev May 16th, 2008 @ 06:28 AM


    "Completeness" aside, I'm still in doubt about adding a full-blown event simulation just to support rare use cases. I would still vote for adding it to unittest.js, though.

  • John-David Dalton

    John-David Dalton May 16th, 2008 @ 04:11 PM

    • State changed from “new” to “enhancement”
  • Steven Pothoven

    Steven Pothoven May 19th, 2008 @ 09:02 PM

    I just want to voice that I was just about to submit a similar ticket myself and would thus be in favor of seeing this addition. I've had to use this functionality in several situations where an Ajax response updates a field value, but the corresponding change event does not get triggered and thus other fields which depend on the first field are not correctly updated.

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 03:55 AM

    • Tag set to patched, section:dom

    [not-tagged:"events" tagged:"section:dom" bulk edit command]

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 03:56 AM

    [not-tagged:"events" tagged:"section:dom" bulk edit command]

  • blatyo

    blatyo August 16th, 2009 @ 06:41 PM

    I would also like to see this feature in prototype. As for its usefulness, I think one of the key benefits would be simulating unsupported dom events, for example DOMNodeInserted.

  • Radoslav Stankov
  • Tobie Langel

    Tobie Langel August 16th, 2009 @ 10:59 PM

    • Tag changed from patched, section:dom to needs:patch, section:dom

    would be useful to have this as a diff against current master.

  • Radoslav Stankov

    Radoslav Stankov August 17th, 2009 @ 12:17 AM

    I have made a patch, I think it don't have any conflicts with the current master. It is only 3 or 4 commits down. If there are any problems with it I could refactor it.

    p.s. this patch includes test for Event.fire + all functional event tests written using Event.fire it self.

  • Samuel Lebeau

    Samuel Lebeau August 26th, 2009 @ 08:07 AM

    • Assigned user set to “Samuel Lebeau”
  • T.J. Crowder

    T.J. Crowder November 16th, 2009 @ 04:50 PM

    • Assigned user cleared.

    [responsible:none bulk edit command]

  • jeuxnewbanat

    jeuxnewbanat March 18th, 2016 @ 01:57 AM

    شكرا على هدا التمرين جيد جدا .... موقع jeuxnewbanat أفضل موقع عربي متخصص في العاب تلبيس بنات جميلة ورائعة انا متاكد انها ستعجبكم كتيرا للانه صراحة العاب جد رائعة ومسلية جدا

  • walis monaim
  • nairy

    nairy November 11th, 2016 @ 12:59 AM

    GREAT TOPIC TNX FOR WORK KEEP WORKING AND play in cooking game the best games al3ab-al3ab10

  • rajaoui2018

    rajaoui2018 September 3rd, 2017 @ 11:54 PM

    تعتبر العاب طبخ جديدة الاكتر شهرة وطلبا في النت فكل الفئات تحبها منها الصغار والكبار و الاولاد و البنات وهي بداتها تحتوي على عدة اصناف وبعدما اصبحت تعرف نجاحا كبيرا اصبحت منتشرة بكترة بين المواقع والكل يحاول تقديم كل ماهو جديد وممتاز فيها ونحن اليوم نقدم لكم نموذج بسيط منها صحيح ان مدونتنا لها اختصاص في تقديم وطرح العاب بنات لكن هذا لا يمنع من ان نغير قليلا وننوع حتى تصبح لدينا تشكيلة جميلة من الالعاب

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins


Referenced by