Last Comment Bug 427537 - Implement CustomEvent DOM3 specification
: Implement CustomEvent DOM3 specification
: 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]
: Andrew Overholt [:overholt]
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:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

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

Description User image 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:
Comment 1 User image 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.
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 User image Aleks Totic 2008-04-07 10:40:43 PDT
Thanks for the tip about datacontainerevent. I wish I found about them earlier.
Comment 3 User image Eli Grey (:sephr) 2011-05-08 09:06:26 PDT
I made a workaround for until this gets fixed:
Comment 4 User image Olli Pettay [:smaug] 2011-05-09 08:52:00 PDT
Created attachment 531057 [details] [diff] [review]
Comment 5 User image Olli Pettay [:smaug] 2011-05-11 00:29:39 PDT

But I managed to mess up with the hg summary.
Fortunately the bug number is there.
Comment 6 User image 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, though I'm not that experienced with MDN page guidelines.
Comment 7 User image 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.