Closed Bug 191960 Opened 23 years ago Closed 23 years ago

[FIXr]DOM events cannot be dispatched to nodes not in the document tree

Categories

(Core :: DOM: Events, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: bzbarsky, Assigned: bzbarsky)

References

Details

Attachments

(2 files, 1 obsolete file)

nsEventListenerManager::DispatchEvent gives up and goes home if its target is not in a document. There's no real reason for it to do that (as far as I can tell, the Events spec just carefully avoids saying what happens when elements are not in a document and events get dispatched on them). Patch coming up, but if we'd rather not do this let me know (and tell me how I _do_ dispatch an event on an element without explicitly getting a prescontext).
Attached patch Proposed fix (obsolete) — Splinter Review
Attachment #113560 - Flags: superreview?(jst)
Attachment #113560 - Flags: review?(bryner)
Summary: DOM events cannot be dispatched to nodes not in the document tree → [FIX]DOM events cannot be dispatched to nodes not in the document tree
Comment on attachment 113560 [details] [diff] [review] Proposed fix //If we don't have a target set this doesn't work. if (mTarget) { nsCOMPtr<nsIContent> targetContent(do_QueryInterface(mTarget)); if (targetContent) { Wanna remove the above redundant if (mTarget) check too while you're poking around here? sr=jst
Attachment #113560 - Flags: superreview?(jst) → superreview+
Attached patch same as diff -wSplinter Review
Attachment #113560 - Attachment is obsolete: true
Attachment #113654 - Flags: superreview?(jst)
Attachment #113654 - Flags: review?(bryner)
Comment on attachment 113654 [details] [diff] [review] same as diff -w sr=jst
Attachment #113654 - Flags: superreview+
Attachment #113654 - Flags: superreview?(jst)
Attachment #113560 - Flags: review?(bryner)
Doing something like this is sort of necessary to implement the spec, which essentially says that you are supposed to bubble events back to nodes even if they were removed from the document during the execution of script handlers: http://www.w3.org/TR/2002/WD-DOM-Level-3-Events-20020712/events.html#Events-flow-capture "The chain of EventTargets from the top of the tree to the event's target is determined before the initial dispatch of the event. If modifications occur to the tree during event processing, event flow will proceed based on the initial state of the tree." It really makes sense to do this anyway--elements which capture fired on should also be bubbled to, and the element which was targeted should always receive the event that was targeted at it--so making us one step closer to being able to do it is a Good Thing.
Comment on attachment 113654 [details] [diff] [review] same as diff -w yeah, sounds ok.
Attachment #113654 - Flags: review?(bryner) → review+
Summary: [FIX]DOM events cannot be dispatched to nodes not in the document tree → [FIXr]DOM events cannot be dispatched to nodes not in the document tree
checked in for 1.4a.
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: