Last Comment Bug 427537 - Implement CustomEvent DOM3 specification
: Implement CustomEvent DOM3 specification
Status: RESOLVED FIXED
: dev-doc-complete
Product: Core
Classification: Components
Component: DOM: Events (show other bugs)
: Trunk
: All All
: -- enhancement with 1 vote (vote)
: mozilla6
Assigned To: Olli Pettay [:smaug]
:
Mentors:
http://dev.w3.org/2006/webapi/DOM-Lev...
Depends on:
Blocks: ietestcenter
  Show dependency treegraph
 
Reported: 2008-04-07 07:45 PDT by Aleks Totic
Modified: 2011-10-26 08:57 PDT (History)
11 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
patch (14.27 KB, patch)
2011-05-09 08:52 PDT, Olli Pettay [:smaug]
jonas: review+
Details | Diff | Review

Description Aleks Totic 2008-04-07 07:45:12 PDT
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b5) Gecko/2008032620 Firefox/3.0b5
Build Identifier: 

CustomEvent is a DOM3 specification, and would make generated events a lot more powerful if implemented. We use js-generated events in XUL for TabOpen, TabClose etc. With current DOM API (createEvent/initEvent), you can't pass any arguments with the event. With CustomEvent API, an extra detail argument is allowed, making events a lot more useful. Trivial example, TabOpen could specify which tab got opened.

Reproducible: Always

Steps to Reproduce:
1.
2.
3.
Comment 1 Olli Pettay [:smaug] 2008-04-07 07:57:29 PDT
DOM 3 Events is still just a *draft* and there will be changes for sure.
(For example I'm going to propose to change CustomEvent interface a bit).

On FF3 extension/chrome developers (well, also web developers could, but it 
isn't recommended) can use gecko-only nsIDOMDataContainerEvent.
http://lxr.mozilla.org/seamonkey/source/dom/public/idl/events/nsIDOMDataContainerEvent.idl
That is actually more flexible than CustomEvent, because it may contain any
number any kind of data, identified using a string key.

var evt = document.createEvent("datacontainerevents");
evt.initEvent("SomeEventName", true, true);
evt.setData("key", "somevalue");

This bug is valid, but just shouldn't be fixed before DOM 3 Events
is a bit more stable.
Comment 2 Aleks Totic 2008-04-07 10:40:43 PDT
Thanks for the tip about datacontainerevent. I wish I found about them earlier.
Comment 3 Eli Grey (:sephr) 2011-05-08 09:06:26 PDT
I made a workaround for until this gets fixed: https://gist.github.com/961460
Comment 4 Olli Pettay [:smaug] 2011-05-09 08:52:00 PDT
Created attachment 531057 [details] [diff] [review]
patch
Comment 5 Olli Pettay [:smaug] 2011-05-11 00:29:39 PDT
http://hg.mozilla.org/mozilla-central/rev/47f42f84ba96

But I managed to mess up with the hg summary.
Fortunately the bug number is there.
Comment 6 Eli Grey (:sephr) 2011-07-23 17:39:49 PDT
trevorh, CustomEvent is an Event class, not a method called document.customEvent(). I've deleted all of your documentation and I'll try to document it myself (the new page is https://developer.mozilla.org/En/DOM/Event/CustomEvent), though I'm not that experienced with MDN page guidelines.
Comment 7 Eli Grey (:sephr) 2011-07-23 18:14:57 PDT
Ok I think it's good now.

Note You need to log in before you can comment on or make changes to this bug.