Closed Bug 97634 Opened 24 years ago Closed 21 years ago

[FIXr]Event.target.parentNode of the Text element passed to a DOMCharacterDataModified/DOMNodeInserted listener is incorrect for a <textarea>'s contents.

Categories

(Core :: DOM: Core & HTML, defect, P2)

defect

Tracking

()

RESOLVED FIXED
mozilla1.7alpha

People

(Reporter: davidemmerson, Assigned: bzbarsky)

References

()

Details

(Keywords: dom2)

Attachments

(1 file)

I've been trying out DOM2's mutation events, specifically to see when a textarea is modified by handling DOMCharacterDataModified and DOMNodeInserted. I am using Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.3+) Gecko/20010827 on win98se. What happens: The events work fine, and the parameter passed to my handler is an event with a target of the modified (or new) Text node. The problem occurs when I try to check if the text node was the one in the <textarea>. event.target.parentNode is returning HTMLDivElement, event.parentNode.parentNode is the HTMLTextAreaElement. What I expect to happen: As a textarea is meant to contain PCDATA in HTML and my document has no <div>s, I expect event.target.parentNode to be the textarea. To reproduce: Go to the url, type something into the box and see the alerted information.
confirming... where does the DIV come from!?
Status: UNCONFIRMED → NEW
Ever confirmed: true
ccing jst.... seems like a weird dom issue
Smells like anonymous content is leaking out to the DOM here, not good.
*** Bug 101197 has been marked as a duplicate of this bug. ***
Over to DOM HTML. This is definitely anonymous content leaking. See testcase in bug 101197
Assignee: joki → jst
Severity: normal → major
Component: DOM Events → DOM HTML
Keywords: dom2
OS: Windows 98 → All
QA Contact: vladimire → stummala
Hardware: PC → All
Future.
Target Milestone: --- → Future
Keywords: mozilla0.9.9
Priority: -- → P3
Still here with Mozilla trunk build 200211208 running under Mac OS 9.2.2.
Mass-reassigning bugs.
Assignee: jst → dom_bugs
*** Bug 225462 has been marked as a duplicate of this bug. ***
The problem here is that the event target is a Text node such never have a bindingParent... as a result, event retargeting does not happen.
Attached patch Proposed patchSplinter Review
This makes Text nodes and other GenericDOMDataNodes implement GetBindingParent() in the only sane way they can -- by looking at their parent. The other option is to retarget for native anonymous content (something I think I may prefer, actually, since the content inside a text control really shouldn't have a binding parent set). The patch also removes the code added to fix bug 29517 since that was obsoleted by the bindingParent-based retargeting (I did test to make sure I didn't regress that bug).
Taking, I guess. Note that with this patch the DOMCharacterDataModified is targeted at the _textarea_, not a Text node. There is no Text node to target it at, really, since the actual Text node in the DOM is not modified when you type in a textarea. Perhaps the textarea should simply suppress mutation events targeted at its kids? Or perhaps our retargeting should generally suppress mutation events, since they don't make very much sense on the new target, usually...
Assignee: general → bz-vacation
Priority: P3 → P2
Summary: Event.target.parentNode of the Text element passed to a DOMCharacterDataModified/DOMNodeInserted listener is incorrect for a <textarea>'s contents. → [FIX]Event.target.parentNode of the Text element passed to a DOMCharacterDataModified/DOMNodeInserted listener is incorrect for a <textarea>'s contents.
Target Milestone: Future → mozilla1.6beta
Comment on attachment 135381 [details] [diff] [review] Proposed patch bryner? jst? What do you think?
Attachment #135381 - Flags: superreview?(jst)
Attachment #135381 - Flags: review?(bryner)
Does this patch have any effect on bug 101197?
No, which is why I reopened that bug.
Comment on attachment 135381 [details] [diff] [review] Proposed patch sr=jst for this patch, but I think supressing mutation events for things inside text inputs is the way to go.
Attachment #135381 - Flags: superreview?(jst) → superreview+
Blocks: 183878
Attachment #135381 - Flags: review?(bryner) → review+
Will land for 1.7a when tree opens.
Summary: [FIX]Event.target.parentNode of the Text element passed to a DOMCharacterDataModified/DOMNodeInserted listener is incorrect for a <textarea>'s contents. → [FIXr]Event.target.parentNode of the Text element passed to a DOMCharacterDataModified/DOMNodeInserted listener is incorrect for a <textarea>'s contents.
Target Milestone: mozilla1.6beta → mozilla1.7alpha
Checked in for 1.7a.
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Component: DOM: HTML → DOM: Core & HTML
QA Contact: stummala → general
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: