Closed Bug 351217 Opened 18 years ago Closed 18 years ago

getElementById return null for elements overlayed into pref-mailnews.xul

Categories

(SeaMonkey :: Preferences, defect)

x86
Windows XP
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: davide.ficano, Assigned: neil)

Details

Attachments

(3 files)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060729 SeaMonkey/1.0.4 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060729 SeaMonkey/1.0.4 I added an id-less <vbox> containing a checkbox (with id) child into pref-mailnews.xul. Then I try to obtain the checkbox element using getElementById but it is always null. Adding an onclick event to checkbox that print document.getElementById(this.id)) I obtain always null. Reproducible: Always Steps to Reproduce: 1. chrome://messenger/content/pref-mailnews.xul 2. open preferences click on 'Mail & Newsgroup' 3. click on 'Click me' checkbox Actual Results: The alert message based on my testcase show null --- null The first null refers to a document.getElementById that receive the id as string The second null refers to document.getElementById(this.id) this.id is correctly set Expected Results: The string indicating the object
Using this file you can reproduce the bug
Attached patch Proposed patchSplinter Review
It looks like that that code path forgets to update the element map.
Assignee: prefs → neil
Status: UNCONFIRMED → ASSIGNED
Attachment #236689 - Flags: superreview?(bzbarsky)
Attachment #236689 - Flags: review?(bzbarsky)
Comment on attachment 236689 [details] [diff] [review] Proposed patch >+ rv = mDocument->InsertElement(mDocument->mRootContent, mOverlay, notify); >+ if (NS_FAILED(rv)) return eResolve_Error; >+ >+ // Add child and any descendants to the element map >+ rv = mDocument->AddSubtreeToDocument(target); Whoops, this should be mOverlay of course... Fixed locally.
Comment on attachment 236689 [details] [diff] [review] Proposed patch >Index: nsXULDocument.cpp > nsXULDocument::OverlayForwardReference::Resolve() >+ // Add child and any descendants to the element map >+ rv = mDocument->AddSubtreeToDocument(target); Won't this call AddSubtreeToDocument twice when |notify| is true? > rv = mDocument->AddSubtreeToDocument(target); For reference that looks pretty wrong to me, since it calls AddSubtreeToDocument multiple times on the same node.... Doesn't really affect this patch, except for the |notify| thing.
Attachment #236689 - Flags: superreview?(bzbarsky)
Attachment #236689 - Flags: superreview-
Attachment #236689 - Flags: review?(bzbarsky)
Attachment #236689 - Flags: review-
Asking jst for review as he was one of the two reviewers who let the double-notify though in the first place and I'm unlikely to get a review from the original author.
Attachment #237106 - Flags: superreview?(bzbarsky)
Attachment #237106 - Flags: review?(jst)
Comment on attachment 237106 [details] [diff] [review] Fixed notify usage r=jst, looks right to me.
Attachment #237106 - Flags: review?(jst) → review+
Comment on attachment 237106 [details] [diff] [review] Fixed notify usage sr=bzbarsky
Attachment #237106 - Flags: superreview?(bzbarsky) → superreview+
Fix checked in to the trunk.
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: